-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing param due to case-sensitive token regex #2925
Comments
Thanks, unfortunately upgrading it comes with some breaking changes, one of them is changing |
Thanks, could you please explain what you think the workaround is? Unfortunately I dont fully understand why this issue should be closed, this issue exists and directly contradicts with the docs which says that all routes are matched case insensitively by default. Wouldnt it be better for visibility to keep this open with a target label like |
This problem also bothers me, which is why I submitted the PR. function escapeIgnoreCase(
text: string
): string {
const holderFlag = "((holderFlag))";
const holderFlagEscape = RegExp.escape(holderFlag);
const holder = text.replace(/[a-zA-Z]/g, a => `${holderFlag}${a}`);
const escapeHolder = RegExp.escape(holder);
const result = escapeHolder.
replace(
new RegExp(`${RegExp.escape(holderFlagEscape)}([a-zA-Z])`, "g"),
a => `[${a.replace(holderFlagEscape, "").toLowerCase()}${a.replace(holderFlagEscape, "").toUpperCase()}]`
);
return result;
}
// escapeIgnoreCase("pt-br"): "[pP][tT]-[bB][rR]"
routes: [{
path: `/:locale(${escapeIgnoreCase("en")}|${escapeIgnoreCase("pt-br")})?/:source(.*)?`,
component: myComponent,
}] |
fyi: path-to-regexp |
Thanks for that! Let's reopen this then. Feel free to upgrade the version to 1.8.0 in a PR |
fixed by #3032 |
Version
3.1.3
Reproduction link
https://jsfiddle.net/j4s8ka1v/
Steps to reproduce
Unfortunately the above reproduction link does not reproduce the issue, not sure why the tokensToFunction method isnt used in the jsfiddle. But I've traced the issue to
tokensToFunction
frompath-to-regexp
. The issue seems to have been fixed in v3.1.0 due to this pr. You can check egdist/vue-router.esm.js
to see the RegExp does not set thei
modifierThat makes this report more or less a fyi / request to upgrade
path-to-regexp
😃Locally the error is caused by a route similar to
which fails when you browse to e.g.
/pt-BR/path
:What is expected?
That the token / param is matched case-insensitively
What is actually happening?
It doesnt, causing a missing param error
The text was updated successfully, but these errors were encountered: