Skip to content

Commit

Permalink
helpers: Return partially cleaned URL in case of error in URLPrep anyway
Browse files Browse the repository at this point in the history
Closes #2987
  • Loading branch information
bep committed Mar 1, 2017
1 parent 74ea81b commit 7acec3c
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions helpers/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"strings"

"github.com/PuerkitoBio/purell"
jww "github.com/spf13/jwalterweatherman"
)

type pathBridge struct {
Expand Down Expand Up @@ -297,17 +296,15 @@ func (p *PathSpec) URLizeAndPrep(in string) string {
// URLPrep applies misc sanitation to the given URL.
func (p *PathSpec) URLPrep(in string) string {
if p.uglyURLs {
x := Uglify(SanitizeURL(in))
return x
return Uglify(SanitizeURL(in))
}
x := PrettifyURL(SanitizeURL(in))
if path.Ext(x) == ".xml" {
return x
pretty := PrettifyURL(SanitizeURL(in))
if path.Ext(pretty) == ".xml" {
return pretty
}
url, err := purell.NormalizeURLString(x, purell.FlagAddTrailingSlash)
url, err := purell.NormalizeURLString(pretty, purell.FlagAddTrailingSlash)
if err != nil {
jww.ERROR.Printf("Failed to normalize URL string. Returning in = %q\n", in)
return in
return pretty
}
return url
}
Expand Down

0 comments on commit 7acec3c

Please sign in to comment.