fix: properly escape `collectionName` in query string parameters (#14476)
parent
ddf9eb1f9a
commit
002b16e1c6
@ -0,0 +1,16 @@
|
|||||||
|
import { buildProviderQuery } from './_tools_util'
|
||||||
|
|
||||||
|
describe('makeProviderQuery', () => {
|
||||||
|
test('collectionName without special chars', () => {
|
||||||
|
expect(buildProviderQuery('ABC')).toBe('provider=ABC')
|
||||||
|
})
|
||||||
|
test('should escape &', () => {
|
||||||
|
expect(buildProviderQuery('ABC&DEF')).toBe('provider=ABC%26DEF')
|
||||||
|
})
|
||||||
|
test('should escape /', () => {
|
||||||
|
expect(buildProviderQuery('ABC/DEF')).toBe('provider=ABC%2FDEF')
|
||||||
|
})
|
||||||
|
test('should escape ?', () => {
|
||||||
|
expect(buildProviderQuery('ABC?DEF')).toBe('provider=ABC%3FDEF')
|
||||||
|
})
|
||||||
|
})
|
||||||
@ -0,0 +1,5 @@
|
|||||||
|
export const buildProviderQuery = (collectionName: string): string => {
|
||||||
|
const query = new URLSearchParams()
|
||||||
|
query.set('provider', collectionName)
|
||||||
|
return query.toString()
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue