Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions core/src/OC/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import Plugins from './plugins.js'
import {
build as buildQueryString,
parse as parseQueryString,
} from './query-string.js'
} from './query-string.ts'
import { getRequestToken } from './requesttoken.ts'
import {
linkToRemoteBase,
Expand Down Expand Up @@ -186,9 +186,7 @@ export default {
*/
getLanguage,

/**
* Query string helpers
*/
// Query string helpers
buildQueryString,
parseQueryString,

Expand Down
75 changes: 0 additions & 75 deletions core/src/OC/query-string.js

This file was deleted.

28 changes: 28 additions & 0 deletions core/src/OC/query-string.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { expect, test } from 'vitest'
import { build, parse } from './query-string.js'

test.for([
['foo', { foo: '' }],
['foo&bar', { foo: '', bar: '' }],
['foo=1', { foo: '1' }],
['foo=1&bar=1+1', { foo: '1', bar: '1 1' }],
['foo=1&bar=1%201', { foo: '1', bar: '1 1' }],
['?foo=1&bar=1%201', { foo: '1', bar: '1 1' }],
] as const)('Parse URL query: $0', ([input, output]) => {
expect(parse(input)).toStrictEqual(output)
})

test.for([
[{ foo: '' }, 'foo='],
[{ foo: '', bar: '' }, 'foo=&bar='],
[{ foo: '1' }, 'foo=1'],
[{ foo: '1', bar: '1 1' }, 'foo=1&bar=1+1'],
[{ foo: 'ümlaut' }, 'foo=%C3%BCmlaut'],
] as const)('Build URL query: $0', ([input, output]) => {
expect(build(input)).toStrictEqual(output)
})
32 changes: 32 additions & 0 deletions core/src/OC/query-string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

/**
* Parses a URL query string into a JS map
*
* @param queryString - Query string in the format param1=1234&param2=abcde&param3=xyz
* @return Object containing key/values matching the URL parameters
* @deprecated 33.0.0 - Use `URLSearchParams` instead
*/
export function parse(queryString: string): Record<string, string> {
const params = new URLSearchParams(queryString)
return Object.fromEntries(params.entries())
}

/**
* Builds a URL query from a JS map.
*
* @param params - Object containing key/values matching the URL parameters
* @return String containing a URL query (without question) mark
* @deprecated 33.0.0 - Use `URLSearchParams` instead
*/
export function build(params: Record<string, string>): string {
if (!params) {
return ''
}

const search = new URLSearchParams(params)
return search.toString()
}
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/core-main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-main.js.map

Large diffs are not rendered by default.

Loading