-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve capitalization of repository URL in links #3649
Conversation
@@ -15,7 +15,7 @@ function init(): void { | |||
.replace(/["']/g, '') | |||
.trim(); | |||
|
|||
const actionURL = new URL(`${location.origin}/${getRepoURL()}/actions`); | |||
const actionURL = new URL(`/${getRepoURL(true)}/actions`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this could be an opportunity make it even more useful:
const actionURL = new URL(`/${getRepoURL(true)}/actions`); | |
const actionURL = new URL(getRepoURL('actions')); |
getRepoURL()
without argument would be used for API calls, selectors and cache keysgetRepoURL(path)
would be use to generate URLs to user pages.
It could go one step further and accept an extra argument, these would be equivalent
const actionURL = new URL(getRepoURL('actions'));
const actionURL = getRepoURL('actions', URL);
Edit: not worth it because there's only one URL built this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. This makes the function a reverse getRepoPath
URL creation is now less noisy too:
- const url = `/${getRepoURL()}/actions`
+ const url = getRepoURL('actions')
- getRepoURL(`a/${b}`) + getRepoURL('a', b)
Last thought: should this be split into 2 functions? function getRepoURL(): string;
function buildRepoURL(...parts: string[]): string; |
At first I thought no, but then I saw your last commit. So 👍 |
Fixes #3648