Merge pull request #1690 from flant/fix-relative-url

Fix templates which asset path points to external URL
This commit is contained in:
Márk Sági-Kazár
2020-09-29 19:47:38 +02:00
committed by GitHub
2 changed files with 12 additions and 0 deletions

View File

@@ -184,6 +184,11 @@ func loadTemplates(c webConfig, templatesDir string) (*templates, error) {
//assetPath is static/main.css
//relativeURL("/dex", "/dex/auth", "static/main.css") = "../static/main.css"
func relativeURL(serverPath, reqPath, assetPath string) string {
if u, err := url.ParseRequestURI(assetPath); err == nil && u.Scheme != "" {
// assetPath points to the external URL, no changes needed
return assetPath
}
splitPath := func(p string) []string {
res := []string{}
parts := strings.Split(path.Clean(p), "/")