1

I have a Chrome extension / web extension that occasionally opens content in new tabs. For example, opening the URL extension://lijpcppdcclkfneghlldocanomgeabja/index.html in a new tab, opens the index.html which is a file inside my extension.

Is there a way to do catchall routing? For example, route the URL extension://lijpcppdcclkfneghlldocanomgeabja/items/(some integer) to a particular page inside the extension?

I have looked in the docs and can't seem to find a mention of any mechanism that allows for an abstraction between extension URL and the files loaded. This seems very odd for a currently maintained platform.

I did find this example of a user using 2010-style #anchor URL routing, but that is a workaround and produces ugly URLs.

mikemaccana
  • 110,530
  • 99
  • 389
  • 494
  • 1
    You can use the standard [SW fetch event](https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/fetch_event) in your `service_worker` script to serve these virtual URLs. Once the page is shown you can use `navigation` API and `history.replaceState`. – wOxxOm May 31 '23 at 19:42

0 Answers0