Cleanup updateQueryString composable
This commit is contained in:
parent
f61fafec2a
commit
934f802be2
|
@ -1,9 +1,5 @@
|
||||||
export default (uri: string, key: string, value: string) => {
|
export default (uri: string, key: string, value: string) => {
|
||||||
const re = new RegExp(`([?&])${key}=.*?(&|$)`, 'i')
|
const url = new URL(uri)
|
||||||
if (uri.match(re)) {
|
url.searchParams.set(key, value)
|
||||||
return uri.replace(re, `$1${key}=${value}$2`)
|
return url.href
|
||||||
} else {
|
|
||||||
const separator = uri.indexOf('?') !== -1 ? '&' : '?'
|
|
||||||
return `${uri}${separator}${key}=${value}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,8 +21,6 @@ const app = createApp({
|
||||||
components: {
|
components: {
|
||||||
App: () => import('~/App.vue')
|
App: () => import('~/App.vue')
|
||||||
},
|
},
|
||||||
setup () {
|
|
||||||
},
|
|
||||||
data: () => ({ isMounted: false }),
|
data: () => ({ isMounted: false }),
|
||||||
async mounted () {
|
async mounted () {
|
||||||
this.isMounted = true
|
this.isMounted = true
|
||||||
|
|
Loading…
Reference in New Issue