mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-30 01:53:34 -05:00
Fix permalinks to subdomains
If you don't have access to the root domain of your site (eg a GitHub project page) and you try to generate custom permalinks, they must begin with a slash. Go's URL resolution library sees the leading slash and thinks "this URL starts at the root", just like a filesystem - so it discards your subdomain and maps all custom permalinks from the root of your site. Fine if you control the root domain, not so useful if you don't. Removing the check for a leading slash fixes this problem. You can now specify custom permalinks that do not start with a slash, and they will map safely regardless of what subdomain you upload the generated site under. Tests have been updated for this commit so that they continue to function.
This commit is contained in:
parent
bdf7cd9f9d
commit
2e954d8551
2 changed files with 1 additions and 5 deletions
|
@ -26,9 +26,6 @@ var knownPermalinkAttributes map[string]PageToPermaAttribute
|
|||
|
||||
// validate determines if a PathPattern is well-formed
|
||||
func (pp PathPattern) validate() bool {
|
||||
if pp[0] != '/' {
|
||||
return false
|
||||
}
|
||||
fragments := strings.Split(string(pp[1:]), "/")
|
||||
var bail = false
|
||||
for i := range fragments {
|
||||
|
|
|
@ -14,9 +14,8 @@ var testdataPermalinks = []struct {
|
|||
}{
|
||||
{"/:year/:month/:title/", true, "/2012/04/spf13-vim-3.0-release-and-new-website/"},
|
||||
{"/:title", true, "/spf13-vim-3.0-release-and-new-website"},
|
||||
{":title", false, ""},
|
||||
{":title", true, "spf13-vim-3.0-release-and-new-website"},
|
||||
{"/blog/:year/:yearday/:title", true, "/blog/2012/97/spf13-vim-3.0-release-and-new-website"},
|
||||
{":fred", false, ""},
|
||||
{"/blog/:fred", false, ""},
|
||||
{"/:year//:title", false, ""},
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue