next-routes icon indicating copy to clipboard operation
next-routes copied to clipboard

Query String Pattern Matching

Open webberwang opened this issue 5 years ago • 2 comments

Can we do something like

pattern: '/page?action=create'

as opposed to

pattern: '/page/create`

because modals should be a child of the parent component in order to keep the background state, as opposed to creating its own route

webberwang avatar Jan 08 '19 08:01 webberwang

From the usage docs of path-to-regexp

Please note: The RegExp returned by path-to-regexp is intended for ordered data (e.g. pathnames, hostnames). It does not handle arbitrary data (e.g. query strings, URL fragments, JSON, etc).

The following are synonymous as I understand it

routes.add('page', '/page')
'/page?action=create'
'/page?action=delete'

routes.add('page', '/page/:action')
'/page/create`
'/page/delete`


const { action } = query

elkwood avatar Jan 08 '19 20:01 elkwood

@elkwood the 2nd approach :action creates a new route though

webberwang avatar Jan 09 '19 03:01 webberwang