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

Use short posts and comments IDs in the URLs #1639

Merged
merged 9 commits into from
Aug 24, 2023
Merged

Use short posts and comments IDs in the URLs #1639

merged 9 commits into from
Aug 24, 2023

Conversation

davidmz
Copy link
Member

@davidmz davidmz commented Aug 19, 2023

This is the client-side part of the Short Links feature.

Added

  • Links to posts and comments are now shorter: e.g. /user/4a39b8 (a post) or /groupname/f482e5#ad2b (a comment).
    • All public URLs and links to posts and comments are now in short format.
    • Addresses of posts and comments with leading slash (/user/...) are now parses in texts as active links.
    • Old-fashion links, with long UIDs, are still fully supported.

@davidmz davidmz requested review from clbn, indeyets and n1313 August 19, 2023 18:08
@github-actions
Copy link

github-actions bot commented Aug 19, 2023

♻️ PR Preview 4bff3e4 has been successfully destroyed since this PR has been closed.

🤖 By surge-preview

Copy link
Contributor

@clbn clbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the short links are not treated as internal ones and are opened in a new tab/window.

Comment on lines 144 to 146
const beforeChars = new RegExp(`[${wordAdjacentChars}]`);
const afterChars = new RegExp(`[${wordAdjacentChars.clone().removeChars('/')}]`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think //clbn/a0f76b should NOT be hyperlinked the same way /clbn/a0f76b/ isn't. (So I would add removeChars('/') to beforeChars as well.)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, it will be linked as /[/clbn/a0f76b], which isn't too bad... Maybe there are some specific cases in which this can lead to incorrect results?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that the default behavior should be to not link text unless we are sure the user's intention is to have a link. And since I can't come up with any legitimate case for having a slash in front of a link, we shouldn't link it the same way we don't link /clbn/a0f76b/.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'd fixed it.

@davidmz davidmz requested a review from clbn August 21, 2023 12:52
clbn
clbn previously approved these changes Aug 21, 2023
Copy link
Contributor

@clbn clbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

src/utils/parse-text.js Outdated Show resolved Hide resolved
Copy link
Contributor

@clbn clbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@davidmz davidmz merged commit 6cb4b5f into stable Aug 24, 2023
@davidmz davidmz deleted the short-links branch August 24, 2023 12:26
@clbn clbn mentioned this pull request Sep 4, 2023
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants