mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-18 21:11:19 +02:00
@@ -292,12 +292,12 @@ func AddContextRoot(baseURL, relativePath string) string {
|
||||
// URLizeAndPrep applies misc sanitation to the given URL to get it in line
|
||||
// with the Hugo standard.
|
||||
func (p *PathSpec) URLizeAndPrep(in string) string {
|
||||
return URLPrep(p.uglyURLs, p.URLize(in))
|
||||
return p.URLPrep(p.URLize(in))
|
||||
}
|
||||
|
||||
// URLPrep applies misc sanitation to the given URL.
|
||||
func URLPrep(ugly bool, in string) string {
|
||||
if ugly {
|
||||
func (p *PathSpec) URLPrep(in string) string {
|
||||
if p.uglyURLs {
|
||||
x := Uglify(SanitizeURL(in))
|
||||
return x
|
||||
}
|
||||
|
@@ -248,7 +248,10 @@ func TestURLPrep(t *testing.T) {
|
||||
{true, "/section/name/index.html", "/section/name.html"},
|
||||
}
|
||||
for i, d := range data {
|
||||
output := URLPrep(d.ugly, d.input)
|
||||
viper.Set("uglyURLs", d.ugly)
|
||||
p := NewPathSpecFromConfig(viper.GetViper())
|
||||
|
||||
output := p.URLPrep(d.input)
|
||||
if d.output != output {
|
||||
t.Errorf("Test #%d failed. Expected %q got %q", i, d.output, output)
|
||||
}
|
||||
|
Reference in New Issue
Block a user