From a5a4422aaeffe0e9df713cf09c73a9cc423a2e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 13 Jun 2022 09:52:02 +0200 Subject: Fix relURL with leading slash when baseURL includes a subdirectory Fixes #9994 --- hugolib/paths/paths.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'hugolib/paths/paths.go') diff --git a/hugolib/paths/paths.go b/hugolib/paths/paths.go index 501665676..e80215b92 100644 --- a/hugolib/paths/paths.go +++ b/hugolib/paths/paths.go @@ -34,6 +34,8 @@ type Paths struct { Cfg config.Provider BaseURL + BaseURLString string + BaseURLNoPathString string // If the baseURL contains a base path, e.g. https://example.com/docs, then "/docs" will be the BasePath. BasePath string @@ -145,10 +147,17 @@ func New(fs *hugofs.Fs, cfg config.Provider) (*Paths, error) { } } + var baseURLString = baseURL.String() + var baseURLNoPath = baseURL.URL() + baseURLNoPath.Path = "" + var baseURLNoPathString = baseURLNoPath.String() + p := &Paths{ - Fs: fs, - Cfg: cfg, - BaseURL: baseURL, + Fs: fs, + Cfg: cfg, + BaseURL: baseURL, + BaseURLString: baseURLString, + BaseURLNoPathString: baseURLNoPathString, DisablePathToLower: cfg.GetBool("disablePathToLower"), RemovePathAccents: cfg.GetBool("removePathAccents"), -- cgit v1.2.3