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

[Bug] Invalid Regular Expression on Safari (iOS) #1703

Open
2 tasks done
omarmir opened this issue Feb 26, 2025 · 0 comments
Open
2 tasks done

[Bug] Invalid Regular Expression on Safari (iOS) #1703

omarmir opened this issue Feb 26, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@omarmir
Copy link
Contributor

omarmir commented Feb 26, 2025

Initial checklist

  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything (or linked relevant results below)

Affected packages and versions

v7.6.3

Link to runnable example

No response

Steps to reproduce

mdast-util-gfm-autolink-literal package uses a lookbehind assertion which is not fully supported in Safari iOS. It causes the component to not render (the Milkdown Editor). This package is used by remark itself. I ended up tracing it through the package chains but I don't have it exactly. In any case, this is likely to cause a problem. @wenxue11 has a forked repo you can override for now:
https://github.com/wenxue11/mdast-util-gfm-autolink-literal

I wanted to post it as an issue for anyone else looking to see a fix. I know its not something you can fix on this package (I suppose you can override too but that feels worse?) but it sems like a good idea to document the issue and present a solution.

How to override in pnpm (though maybe fork wenxue11's repo)

"pnpm": {
    "overrides": {
      "mdast-util-gfm-autolink-literal": "github:wenxue11/mdast-util-gfm-autolink-literal"
    }
  }

They have changed the regex for iOS compatability:

/** @type {FromMarkdownTransform} */
function transformGfmAutolinkLiterals(tree) {
  findAndReplace(
    tree,
    [
      [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, findUrl],
      -[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, findEmail]
      +[/(?:^|\s|[!"#$%&'()*+,\-./:;<=>?@[\\]^_`{|}~])([-.\\w+]+)@([-\w]+(?:\.[-\w]+)+)/gi, findEmail]
    ],
    {ignore: ['link', 'linkReference']}
  )
}

Expected behavior

For it to render the editor.

Actual behavior

Doesn't render the editor.

Runtime

Safari

OS

Other (please specify in steps to reproduce)

Build and bundle tools

Vite

@omarmir omarmir added the bug Something isn't working label Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants