varnishtest "test regsub(NULL)"

server s1 {
	rxreq
	expect req.url == "/bar"
	txresp -body "foobar"
} -start

varnish v1 -vcl+backend {
	sub vcl_backend_response {
		if (beresp.http.bar ~ "$") {
			set beresp.http.foo = regsub(beresp.http.bar, "$", "XXX");
		}
	}
} -start

client c1 {
	txreq  -url /bar
	rxresp
	expect resp.bodylen == 6
	expect resp.http.foo == "XXX"
} -run
