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

Fixing/improving linkRegExp #453

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Fixing/improving linkRegExp #453

wants to merge 2 commits into from

Conversation

oyv
Copy link

@oyv oyv commented Jan 13, 2024

linkRegExp seemed to not quite work as intended if modified by the user. This attempts to fix some issues with custom linkRegExp, and add some nice to have features. Take what you want, cheers.

oyv added 2 commits January 13, 2024 22:15
Solves/improves the following:
- Setting a custom linkRegExp messes with the logic for adding
  protocol or mailto. Use named capture groups in the regex, and
  add a case in the href generation that just uses the match
  directly if neither the url nor the email regex matches, which
  would mean that the user's custom regex matched instead.
- Make https the default protocol instead of http
- Use a more general regex for matching the protocol.

Signed-off-by: Øyvind Rønningstad <[email protected]>
A map of capture groups to functions for producing the href of a
link. By default, it is e.g. used to prepend https:// to links
matching on www. so they are not interpreted as relative.
The user can add their own handlers if modifying linkRegExp.

Signed-off-by: Øyvind Rønningstad <[email protected]>
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.

1 participant