Closed dkarlovi closed 1 year ago
Hello @dkarlovi. It doesn't support the relative URLs yet but it could be supported with a check here https://github.com/darkweak/go-esi/blob/master/esi/include.go#L55. The check could be like
// include.go
var rgStartsWithSlash = regexp.MustCompile("^/[^/].+")
//....
// L.55
if rgStartsWithSlash.MatchString(i.src) {
// Get infos from req.URL
i.src = req.URL.Scheme + req.URL.Host + i.src
}
Wouldn't it be faster to just check the first char, without a regex?
Either way, I'll try a PR with this, thanks for the pointers!
No because it could be //domain.com/something
that is not valid but possible URL without scheme and we shouldn't prefix with the initial request scheme + host
If leading //
, it doesn't need the scheme + host, else if leading /
it does, maybe?
You're right, it would be simpler to use only conditions and could write the fix with these conditions
//
then add the scheme (because the golang client request need the scheme)/
then add the scheme + host
I notice you're using full URLs in all examples. Symfony ESI will by default generate hostless URLs when generating the ESI include block: https://symfony.com/doc/current/http_cache/esi.html
Are these supported?
Example: