Worker on / only

I need to add a worker to run on requests for
However the docs say routes cannot contain a querystring.

If I enter a route of:
The worker runs but also runs on every other page or image on the site which is no use to me

If I enter a route of:
The worker doesn’t appear to be getting invoked on requests for Example Domain

What route should I be using? as the route should be enough.

To achieve this result you could use the URL constructor.


addEventListener('fetch', event => {

async function handleRequest(event) {
	const {request} = event
	const url = new URL(request.url)
	const {searchParams} = url
		const testVal = searchParams.get('test');
		return new Response(`test value is: ${testVal}`)
	//fallback Response
	return await fetch(request)