From: Eduardo San Martin Morote Date: Thu, 26 Sep 2019 16:11:02 +0000 (+0200) Subject: fix: adapt route ranking X-Git-Tag: v4.0.0-alpha.0~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8df0afcb82ae5507bcf90deca03e11956b46b526;p=thirdparty%2Fvuejs%2Frouter.git fix: adapt route ranking --- diff --git a/src/matcher.ts b/src/matcher.ts index 7fe9998f..a283776c 100644 --- a/src/matcher.ts +++ b/src/matcher.ts @@ -57,13 +57,20 @@ const enum PathScore { Wildcard = -1 * _multiplier, // /:namedWildcard(.*) SubWildcard = 1 * _multiplier, // Wildcard as a subsegment Repeatable = -0.5 * _multiplier, // /:w+ or /:w* - Strict = 0.7 * _multiplier, // when options strict: true is passed, as the regex omits \/? - CaseSensitive = 0.25 * _multiplier, // when options strict: true is passed, as the regex omits \/? + // these two have to be under 0.1 so a strict /:page is still lower than /:a-:b + Strict = 0.07 * _multiplier, // when options strict: true is passed, as the regex omits \/? + CaseSensitive = 0.025 * _multiplier, // when options strict: true is passed, as the regex omits \/? Optional = -4 * _multiplier, // /:w? or /:w* SubOptional = -0.1 * _multiplier, // optional inside a subsegment /a-:w? or /a-:w* Root = 1 * _multiplier, // just / } +/** + * Non Working Rankings: + * - ?p=AAOsIPQgYAEL9lNgQAGKBeACgQMODLpiY5C0gAQYhGyZkaNyaRFZOwOOkPODO_HsENkAAA.. + * the case sensitive and the strict option on the optional parameter `/:a-:w?` or `/:a?-:w` will come before `/:a-b` + */ + // allows to check if the user provided a custom regexp const isDefaultPathRegExpRE = /^\[\^[^\]]+\]\+\?$/