-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
breaking: Remove trailing slash from base_url and base_path outputs
- Loading branch information
James M. Greene
authored and
James M. Greene
committed
Aug 18, 2022
1 parent
9a14197
commit dc5b850
Showing
3 changed files
with
21 additions
and
10 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,21 @@ | ||
| const core = require('@actions/core') | ||
|
|
||
| function removeTrailingSlash(str) { | ||
| if (str.endsWith('/')) { | ||
| str = str.slice(0, -1) | ||
| } | ||
| return str | ||
| } | ||
|
|
||
| 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