Skip to content

Commit f6c47d7

Browse files
authored
Merge pull request #6529 from remix-project-org/yann300-patch-67
Implement exists method in query-params.ts
2 parents bd2d05a + 5351337 commit f6c47d7

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

libs/remix-lib/src/query-params.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,21 @@ export class QueryParams {
1111
let queryString = '#'
1212
const updatedKeys = Object.keys(currentParams)
1313
for (const y in updatedKeys) {
14-
queryString += updatedKeys[y] + '=' + currentParams[updatedKeys[y]] + '&'
14+
if (currentParams[updatedKeys[y]]) {
15+
queryString += updatedKeys[y] + '=' + currentParams[updatedKeys[y]] + '&'
16+
} else {
17+
queryString += updatedKeys[y] + '&'
18+
}
19+
1520
}
1621
window.location.hash = queryString.slice(0, -1)
1722
}
1823

24+
exists (key) {
25+
const params = this.get()
26+
return Object.keys(params).includes(key)
27+
}
28+
1929
get () {
2030
const qs = window.location.hash.substr(1)
2131

0 commit comments

Comments
 (0)