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 Report β€” URLPattern behaviour #3533

Open
elpy1 opened this issue Feb 12, 2025 · 1 comment
Open

πŸ› Bug Report β€” URLPattern behaviour #3533

elpy1 opened this issue Feb 12, 2025 · 1 comment
Assignees

Comments

@elpy1
Copy link

elpy1 commented Feb 12, 2025

I'm trying to use the URLPattern API for testing a given URL against a URL pattern but I'm getting unexpected behaviour compared to Chrome.

URL: https://www.youtube.com/watch?v=Yw6u6YkTgQ4
Pattern: https://*.youtube.com/watch*

Worker:

const pattern = new URLPattern('https://*.youtube.com/watch*');

console.log(pattern);
URLPattern {
  protocol: 'https',
  username: '',
  password: '',
  hostname: '*.youtube.com',
  port: '',
  pathname: '/watch*',
  search: '',
  hash: ''
}

pattern.test('https://www.youtube.com/watch?v=Yw6u6YkTgQ4');
false

pattern.exec('https://www.youtube.com/watch?v=Yw6u6YkTgQ4');
null

Chrome:

const pattern = new URLPattern('https://*.youtube.com/watch*');

console.log(pattern);
URLPattern {
  hasRegExpGroups: false,
  hash: "*",
  hostname: "*.youtube.com",
  password: "*",
  pathname: "/watch*",
  port: "",
  protocol: "https",
  search: "*",
  username: "*",
}

pattern.test('https://www.youtube.com/watch?v=Yw6u6YkTgQ4');
true
@elpy1 elpy1 changed the title URLPattern test behaviour πŸ› Bug Report β€” URLPattern behaviour Feb 12, 2025
@anonrig
Copy link
Member

anonrig commented Feb 12, 2025

Thanks for the bug report. This will be fixed with #3529

@anonrig anonrig self-assigned this Feb 12, 2025
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

No branches or pull requests

2 participants