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:
parent
a9c8bf9a90
commit
98b17e5b22
2 changed files with 11 additions and 10 deletions
|
@ -22,16 +22,17 @@ interface URLFormatOptions {
|
|||
}
|
||||
|
||||
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 || ''
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit e224260a00437bca1338641b4da4dc5cca627016
|
||||
Subproject commit 230f069aa4f957d57bc6aa37c80099be3ed28489
|
Loading…
Add table
Add a link
Reference in a new issue