]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
refactor: use exported regex
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 13 Nov 2020 14:19:05 +0000 (15:19 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 13 Nov 2020 14:19:05 +0000 (15:19 +0100)
src/encoding.ts
src/query.ts

index 47964c47178426894bf6539197f84180f59bb2ff..5207d417ac3b7049c255306882020861999d8838 100644 (file)
@@ -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
index e7903c4bf2728b8012b104552b861042a4d471b4..7d62be276f2c93aa56625808f1970b6680a27493 100644 (file)
@@ -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))