Skip to content
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

Merged
merged 6 commits into from
Oct 15, 2020
Merged

Conversation

fregante
Copy link
Member

Fixes #3648

@fregante fregante added the bug label Oct 14, 2020
@@ -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`);
Copy link
Member Author

@fregante fregante Oct 14, 2020

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:

Suggested change
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 keys
  • getRepoURL(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.

Copy link
Member Author

@fregante fregante Oct 14, 2020

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')

@fregante
Copy link
Member Author

fregante commented Oct 14, 2020

Last thought: should this be split into 2 functions?

function getRepoURL(): string;
function buildRepoURL(...parts: string[]): string;

@yakov116
Copy link
Member

At first I thought no, but then I saw your last commit. So 👍

@fregante fregante merged commit b7d31c6 into master Oct 15, 2020
@fregante fregante deleted the original-repo-url branch October 15, 2020 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Release links are lowercased
2 participants