Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit 62529c3

Browse files
author
Alan Shaw
committed
chore: appease linter
License: MIT Signed-off-by: Alan Shaw <alan.shaw@protocol.ai>
1 parent 636d302 commit 62529c3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/lib/querystring.browser.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
exports.objectToQuery = obj => {
66
if (!obj) return ''
77

8-
let qs = new URLSearchParams()
9-
10-
for (const [key, value] of Object.entries(obj)) {
8+
let qs = Object.entries(obj).forEach(([key, value]) => {
119
if (value != null) {
1210
if (Array.isArray(value)) {
1311
value.forEach(v => qs.append(key, v))
1412
} else {
1513
qs.append(key, value)
1614
}
1715
}
18-
}
16+
})
1917

2018
qs = qs.toString()
2119

src/lib/querystring.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ const Qs = require('qs')
77
exports.objectToQuery = obj => {
88
if (!obj) return ''
99

10-
const qs = Object.entries(obj).reduce((obj, [key, value]) => {
10+
let qs = Object.entries(obj).reduce((obj, [key, value]) => {
1111
if (value != null) obj[key] = value
1212
return obj
1313
}, {})
1414

15-
return Object.keys(qs).length ? `?${Qs.stringify(qs, { arrayFormat: 'repeat' })}` : ''
15+
qs = Qs.stringify(qs, { arrayFormat: 'repeat' })
16+
17+
return qs ? `?${qs}` : qs
1618
}

0 commit comments

Comments
 (0)