-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from actions/no-trailing-slashes
[BREAKING] Remove the trailing slash from `base_url` and `base_path` outputs
- Loading branch information
Showing
7 changed files
with
42 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,15 @@ | ||
const core = require('@actions/core') | ||
const removeTrailingSlash = require('./remove-trailing-slash') | ||
|
||
function outputPagesBaseUrl(siteUrl) { | ||
core.setOutput('base_url', siteUrl.href) | ||
// Many static site generators do not want the trailing slash, and it is much easier to add than remove in a workflow | ||
const baseUrl = removeTrailingSlash(siteUrl.href) | ||
const basePath = removeTrailingSlash(siteUrl.pathname) | ||
|
||
core.setOutput('base_url', baseUrl) | ||
core.setOutput('origin', siteUrl.origin) | ||
core.setOutput('host', siteUrl.host) | ||
core.setOutput('base_path', siteUrl.pathname) | ||
core.setOutput('base_path', basePath) | ||
} | ||
|
||
module.exports = outputPagesBaseUrl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = function removeTrailingSlash(str) { | ||
return str.endsWith('/') ? str.slice(0, -1) : str | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters