Skip to content

Commit 3110225

Browse files
committed
refactor: use exported regex
1 parent 52e0656 commit 3110225

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/encoding.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const AMPERSAND_RE = /&/g // %26
2323
const SLASH_RE = /\//g // %2F
2424
const EQUAL_RE = /=/g // %3D
2525
const IM_RE = /\?/g // %3F
26-
const PLUS_RE = /\+/g // %2B
26+
export const PLUS_RE = /\+/g // %2B
2727
/**
2828
* NOTE: It's not clear to me if we should encode the + symbol in queries, it
2929
* seems to be less flexible than not doing so and I can't find out the legacy

src/query.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { decode, encodeQueryKey, encodeQueryValue } from './encoding'
1+
import { decode, encodeQueryKey, encodeQueryValue, PLUS_RE } from './encoding'
22

33
/**
44
* Possible values in normalized {@link LocationQuery}
@@ -51,8 +51,7 @@ export function parseQuery(search: string): LocationQuery {
5151
const searchParams = (hasLeadingIM ? search.slice(1) : search).split('&')
5252
for (let i = 0; i < searchParams.length; ++i) {
5353
// pre decode the + into space
54-
// FIXME: can't import PLUS_RE because it becomes a different regex ???
55-
const searchParam = searchParams[i].replace(/\+/g, ' ')
54+
const searchParam = searchParams[i].replace(PLUS_RE, ' ')
5655
// allow the = character
5756
let eqPos = searchParam.indexOf('=')
5857
let key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos))

0 commit comments

Comments
 (0)