@toddledev/core
Advanced tools
@@ -12,5 +12,9 @@ const LOCALHOSTS = ['http://localhost:54404', 'http://preview.localhost:54404']; | ||
// So we need to iterate over them to make sure they are encoded as that happens when setting them explicitly | ||
urlObject.searchParams.forEach((value, key) => { | ||
urlObject.searchParams.set(key, value); | ||
const searchCopy = new URLSearchParams(urlObject.searchParams); | ||
searchCopy.forEach((value, key) => { | ||
urlObject.searchParams.delete(key, value); | ||
}); | ||
searchCopy.forEach((value, key) => { | ||
urlObject.searchParams.append(key, value); | ||
}); | ||
return urlObject; | ||
@@ -17,0 +21,0 @@ } |
@@ -17,3 +17,3 @@ { | ||
"main": "dist/index.js", | ||
"version": "0.0.5-alpha.1" | ||
"version": "0.0.5-alpha.2" | ||
} |
@@ -9,2 +9,10 @@ import { describe, expect, test } from '@jest/globals' | ||
}) | ||
test('it validates urls arrays in query params correctly', async () => { | ||
const url = validateUrl('https://toddle.dev?test=1&test=2') | ||
expect(url).toBeInstanceOf(URL) | ||
if (url instanceof URL) { | ||
expect(url.searchParams.getAll('test')).toEqual(['1', '2']) | ||
} | ||
}) | ||
}) |
@@ -18,5 +18,9 @@ const LOCALHOSTS = ['http://localhost:54404', 'http://preview.localhost:54404'] | ||
// So we need to iterate over them to make sure they are encoded as that happens when setting them explicitly | ||
urlObject.searchParams.forEach((value, key) => { | ||
urlObject.searchParams.set(key, value) | ||
const searchCopy = new URLSearchParams(urlObject.searchParams) | ||
searchCopy.forEach((value, key) => { | ||
urlObject.searchParams.delete(key, value) | ||
}) | ||
searchCopy.forEach((value, key) => { | ||
urlObject.searchParams.append(key, value) | ||
}) | ||
return urlObject | ||
@@ -23,0 +27,0 @@ } catch { |
Sorry, the diff of this file is not supported yet
377254
0.21%8677
0.17%32
-3.03%