From 2d77f0018b3b7febe45744512d51c2f0d828bc2e Mon Sep 17 00:00:00 2001 From: Danny Varner Date: Thu, 5 Jul 2018 15:44:42 -0700 Subject: [PATCH 1/2] Add trailing slash to permalink This is required due to [gitlab-pages issue #9](https://gitlab.com/gitlab-org/gitlab-pages/issues/9) --- lib.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib.js b/lib.js index bcfb22b..5bb46ce 100644 --- a/lib.js +++ b/lib.js @@ -49,7 +49,7 @@ module.exports = (options) => { const uploadChallenge = (key, value, repo, domain) => { const challengeContent = options.jekyll ? - `---\nlayout: null\npermalink: /.well-known/acme-challenge/${key}\n---\n${value}` : value; + `---\nlayout: null\npermalink: /.well-known/acme-challenge/${key}/\n---\n${value}` : value; // Need to bluebird-ify to use .asCallback() const filePath = encodeURIComponent(path.posix.resolve('/', options.path, key)); return Promise.resolve(gitlabRequest.post({ From 0a682c5ceb53d0a6684c9105245cf4483e3e38eb Mon Sep 17 00:00:00 2001 From: Danny Varner Date: Thu, 5 Jul 2018 16:24:10 -0700 Subject: [PATCH 2/2] Use a filePath that is compatible with Jekyll Changes the path of /.well-known/acme-challange/{key} to /letencrypt.html when --jekyll is used Resolves 2 issues: 1. By default, Jekyll does not build any files or directories that start with a '.'. This causes the default path of starting with .well-known to not work when --jekyll flag is used. 2. Even if the --path option is used to point the {key} file to a non-hidden directory, jekyll gets confused with the lack of a .html extension and doesn't render it properly --- lib.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib.js b/lib.js index 5bb46ce..b9644fd 100644 --- a/lib.js +++ b/lib.js @@ -51,7 +51,7 @@ module.exports = (options) => { const challengeContent = options.jekyll ? `---\nlayout: null\npermalink: /.well-known/acme-challenge/${key}/\n---\n${value}` : value; // Need to bluebird-ify to use .asCallback() - const filePath = encodeURIComponent(path.posix.resolve('/', options.path, key)); + const filePath = options.jekyll ? "letsencrypt.html" : encodeURIComponent(path.posix.resolve('/', options.path, key)); return Promise.resolve(gitlabRequest.post({ url: `/projects/${repo.id}/repository/files/${filePath}`, body: { @@ -64,7 +64,7 @@ module.exports = (options) => { }; const deleteChallenges = (key, repo) => { - const filePath = encodeURIComponent(path.posix.resolve('/', options.path, key)); + const filePath = options.jekyll ? "letsencrypt.html" : encodeURIComponent(path.posix.resolve('/', options.path, key)); return Promise.resolve(gitlabRequest.delete({ url: `/projects/${repo.id}/repository/files/${filePath}`, body: {