Skip to content

Commit

Permalink
Merge pull request #39 from getAlby/fix/build-query-string
Browse files Browse the repository at this point in the history
fix: build query string util function double &
  • Loading branch information
rolznz authored Aug 18, 2023
2 parents a04dbc0 + ab24c4d commit c074f41
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// https://stackoverflow.com/a/62969380
export function buildQueryString(query: Record<string, any>): string {
// https://stackoverflow.com/a/62969380 + fix to remove empty entries (.filter(entry => entry))
export function buildQueryString(query: Record<string, unknown>): string {
return Object.entries(query)
.map(([key, value]) => (key && value ? `${key}=${value}` : ""))
.filter((entry) => entry)
.join("&");
}

Expand Down

0 comments on commit c074f41

Please sign in to comment.