Extract getDynamicParam to a shared module (#82137)
I'm in the midst of a refactor to move dynamic route param parsing to
the client. This way client components can extract route params from the
browser URL without needing to make a server request. For example, if a
page is completely rendered on the client, we should be able to change
the URL without a request, even if the page accesses params.
In this PR, I've extracted the logic for parsing dynamic params into a
shared module. It's not actually loaded on the client yet, but I wanted
to move this into a separate file as its own step to make sure it works
on its own.
We need to be careful not to make this logic any more complex than it
needs to be. Ideally it would be little more than a regex. For most
params, that's the case, but alas there's already some unfortunate
special case handling for catchall routes.