-
Notifications
You must be signed in to change notification settings - Fork 64
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
lookbehind not supported on safari < 17 #143
Comments
I'm no regExp expert I was just going by this for rough equiv of look behind https://stackoverflow.com/a/74994273/738957 |
Please check the latest version |
Current fix gives wrong capture group results, as there are more capture groups in the lookaround-supporting regex than there are in the compat-mode regex: const OriginalRegExp = globalThis.RegExp;
class SafariRegExp extends OriginalRegExp {
constructor(pattern, flags) {
super(pattern, flags)
if (String(pattern).includes('(?<=')) {
throw new SyntaxError('idk what (?<= even means')
}
}
}
globalThis.RegExp = SafariRegExp
const anchorme = (await import('https://esm.sh/v135/[email protected]')).default
console.info(
anchorme.list(
`https://example.xyz example.com [email protected] file:///filename.txt 192.168.1.1`,
false,
)
)
// expected:
[
{ start: 0, end: 19, string: 'https://example.xyz', isURL: true, protocol: 'https://', /* ... */ },
{ start: 20, end: 31, string: 'example.com', isURL: true, protocol: undefined, /* ... */ },
{ start: 32, end: 46, string: '[email protected]', isEmail: true, local: 'user', /* ... */ },
{ start: 47, end: 67, string: 'file:///filename.txt', isFile: true, protocol: 'file:///', /* ... */ },
{ start: 68, end: 79, string: '192.168.1.1', isURL: true, protocol: undefined, /* ... */ },
]
// actual:
[
{ start: 0, end: 19, string: 'https://example.xyz', reason: 'unknown' },
{ start: 20, end: 31, string: 'example.com', reason: 'unknown' },
{ start: 32, end: 46, string: '[email protected]', reason: 'unknown' },
{ start: 47, end: 67, string: 'file:///filename.txt', isURL: true, protocol: undefined, /* ... */ },
{ start: 68, end: 79, string: '192.168.1.1', reason: 'unknown' },
] I'll have a PR up with a fix shortly — I think with the fix, |
Hi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch
[email protected]
for the project I'm working on.Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: