From 3d30a0969587f998ffbbb21a8ae99b840762fe28 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Wed, 6 Mar 2019 10:44:32 -0500 Subject: [PATCH] Fix IsValidUsername check when PagesParentDir isn't current dir Previously, this check would only work if there was a pages/ dir in the current working directory. Now it respects the pages_parent_dir configuration setting. --- author/author.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/author/author.go b/author/author.go index c7a5ae0..bf3bfe1 100644 --- a/author/author.go +++ b/author/author.go @@ -112,8 +112,7 @@ func IsValidUsername(cfg *config.Config, username string) bool { // Username is invalid if page with the same name exists. So traverse // available pages, adding them to reservedUsernames map that'll be checked // later. - // TODO: use pagesDir const - filepath.Walk("pages/", func(path string, i os.FileInfo, err error) error { + filepath.Walk(filepath.Join(cfg.Server.PagesParentDir, "pages"), func(path string, i os.FileInfo, err error) error { reservedUsernames[i.Name()] = true return nil })