Worker on / only

I need to add a worker to run on requests for
.example.com/?test=
However the docs say routes cannot contain a querystring.

If I enter a route of:
.example.com/
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:
*.example.com/
The worker doesn’t appear to be getting invoked on requests for Example Domain

What route should I be using?

.example.com/ as the route should be enough.

To achieve this result you could use the URL constructor.

Example:

addEventListener('fetch', event => {
    event.respondWith(handleRequest(event));
});

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