1

I am running into some issues when attempting to use documentUrlPatterns with my web extension, on Safari, when creating context menu items.

Example:

browser.contextMenus.create({id: "12354", title: "Test01",documentUrlPatterns:["https://www.linkedin.com/feed/"]});

When using documentUrlPatterns on any website with an explicit pathname (as shown above), the context menu item does not get created for matching document urls.

With the above code I would expect to see a context menu item on https://www.linkedin.com/feed/ with the title Test01, but nothing appears. As mentioned, it seems any explicit path name, such as /feed/ or /someother/page/ on any website presents this issue.

My understanding of how matching works makes me think that explicit path names are valid in patterns, but perhaps I am missing something.

If I drop the last trailing slash /, the context menu item seems to be created as expected.

Is my expected outcome valid or is there something unique about the way documentUrlPatterns works that I am missing?

The above code seems to work as intended in Chrome and Firefox. I imagine this could be an Apple Safari related bug but before reporting it, I was curious if there's something I am missing.

Paul Verest
  • 60,022
  • 51
  • 208
  • 332
justinw
  • 3,856
  • 5
  • 26
  • 41
  • 1
    Looks like the [trailing slash matters](https://searchfacts.com/url-trailing-slash/) so there seems to be a bug in Safari. – wOxxOm Jul 18 '21 at 17:13
  • @wOxxOm yeah, I think you're right. I posted it in the Apple forums to see if there is some idiosyncrasy, but if Apple's goal is to have Safari Web Extensions function like Chrome and Firefox, then there's certainly something wrong. – justinw Jul 18 '21 at 17:21

0 Answers0