mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
url query formatting fix, removed trailing ?
This commit is contained in:
@@ -22,16 +22,17 @@ interface URLFormatOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatUrl(options: URLFormatOptions): string {
|
function formatUrl(options: URLFormatOptions): string {
|
||||||
console.log(options.pathname, options.query)
|
|
||||||
const queryString = options.query
|
|
||||||
? '?' +
|
|
||||||
Object.keys(options.query)
|
|
||||||
.map((key) => {
|
|
||||||
return `${key}=${encodeURIComponent(options.query[key])}`
|
|
||||||
})
|
|
||||||
.join('&')
|
|
||||||
: ''
|
|
||||||
const path = options.pathname || ''
|
const path = options.pathname || ''
|
||||||
|
if (!options.query || Object.keys(options.query).length === 0) {
|
||||||
|
return path
|
||||||
|
}
|
||||||
|
const queryString =
|
||||||
|
'?' +
|
||||||
|
Object.keys(options.query)
|
||||||
|
.map((key) => {
|
||||||
|
return `${key}=${encodeURIComponent(options.query[key])}`
|
||||||
|
})
|
||||||
|
.join('&')
|
||||||
return path + queryString
|
return path + queryString
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Submodule submodules/qmining-page updated: e224260a00...230f069aa4
Reference in New Issue
Block a user