path-to-regexp icon indicating copy to clipboard operation
path-to-regexp copied to clipboard

How would I match a path disregarding the query?

Open AaronBeaudoin opened this issue 4 years ago • 0 comments

I want to rewrite a path starting with /some/path whether or not it has a trailing slash (or a sub route), and ignores the query, simply copying it to the new path unchanged.

/some/path          --> /other/path
/some/path/         --> /other/path/
/some/path?a=b      --> /other/path?a=b
/some/path/?a=b     --> /other/path/?a=b
/some/path/sub      --> /other/path/sub
/some/path/sub/     --> /other/path/sub/
/some/path/sub?a=b  --> /other/path/sub?a=b
/some/path/sub/?a=b --> /other/path/sub/?a=b

I haven't been able to figure out how to do this with path-to-regexp.

AaronBeaudoin avatar Dec 07 '21 18:12 AaronBeaudoin