import (
"fmt"
- "github.com/PuerkitoBio/purell"
- "github.com/spf13/viper"
"net/url"
"path"
"strings"
+
+ "github.com/PuerkitoBio/purell"
+ "github.com/spf13/viper"
)
type PathBridge struct {
newPath := path.Join(url.Path, relativePath)
- // path strips traling slash
- if strings.HasSuffix(relativePath, "/") {
+ // path strips traling slash, ignore root path.
+ if newPath != "/" && strings.HasSuffix(relativePath, "/") {
newPath += "/"
}
return newPath
// cannot guess that the context root is already added int the example below
{"http://example.com/sub/", "/sub/foo", "/sub/sub/foo"},
{"http://example.com/тря", "/трям/", "/тря/трям/"},
+ {"http://example.com", "/", "/"},
+ {"http://example.com/bar", "//", "/bar/"},
}
for _, test := range tests {