I'm working in a 3rd party code base and trying to understand the search param extraction for the following URL
https://example.com/books?filters.author=1c32323cc-fac5-4c5e-a7d3-a5379cdc4417
in the following Mock Service Worker route
rest.get(/books[^/]*$/, (req, res, ctx) => {
const author = req.url.searchParams.get('filter[author]');
return res(ctx.status(200), ctx.json({ author }));
}
With the URL above, it does correctly return the author id specified in the URL param.
I'm struggling to understand the why though. In the url, dot notation is used and "filters", whereas in the msw route braket notation is used and "filter" (without s). I'm trying to understand why req.url.searchParams.get('filter[author]')
correctly extracts from filters.author
in the URL.
Is this a feature of msw (I can't find anything in the documentation)?