From: Eduardo San Martin Morote Date: Fri, 13 Nov 2020 14:19:05 +0000 (+0100) Subject: refactor: use exported regex X-Git-Tag: v4.0.0-rc.3~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3110225b69e58aac5deb05fc0f9642ec64ddc31f;p=thirdparty%2Fvuejs%2Frouter.git refactor: use exported regex --- diff --git a/src/encoding.ts b/src/encoding.ts index 47964c47..5207d417 100644 --- a/src/encoding.ts +++ b/src/encoding.ts @@ -23,7 +23,7 @@ const AMPERSAND_RE = /&/g // %26 const SLASH_RE = /\//g // %2F const EQUAL_RE = /=/g // %3D const IM_RE = /\?/g // %3F -const PLUS_RE = /\+/g // %2B +export const PLUS_RE = /\+/g // %2B /** * NOTE: It's not clear to me if we should encode the + symbol in queries, it * seems to be less flexible than not doing so and I can't find out the legacy diff --git a/src/query.ts b/src/query.ts index e7903c4b..7d62be27 100644 --- a/src/query.ts +++ b/src/query.ts @@ -1,4 +1,4 @@ -import { decode, encodeQueryKey, encodeQueryValue } from './encoding' +import { decode, encodeQueryKey, encodeQueryValue, PLUS_RE } from './encoding' /** * Possible values in normalized {@link LocationQuery} @@ -51,8 +51,7 @@ export function parseQuery(search: string): LocationQuery { const searchParams = (hasLeadingIM ? search.slice(1) : search).split('&') for (let i = 0; i < searchParams.length; ++i) { // pre decode the + into space - // FIXME: can't import PLUS_RE because it becomes a different regex ??? - const searchParam = searchParams[i].replace(/\+/g, ' ') + const searchParam = searchParams[i].replace(PLUS_RE, ' ') // allow the = character let eqPos = searchParam.indexOf('=') let key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos))