Skip to content

Commit e7a065c

Browse files
percent encode endpoint path (#40)
* percent encode endpoint path * chore: document changes * chore: added changeset --------- Co-authored-by: Alex Iglesias <alexiglesias@finsweet.com>
1 parent 3391f70 commit e7a065c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'fireworkers': patch
3+
---
4+
5+
fix: support document IDs that contain hashes

src/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export const get_firestore_endpoint = (
1414
const allPaths = ['v1', 'projects', project_id, 'databases', '(default)', 'documents', ...paths];
1515
const path = allPaths.join('/') + suffix;
1616

17-
const endpoint = new URL(path, FIRESTORE_ENDPOINT);
17+
const endpoint = new URL(FIRESTORE_ENDPOINT);
18+
19+
// We assign the pathname after instanciating the URL to ensure any hashes are encoded as part of the patname.
20+
// This is done to support use cases where users have hashes in their document IDs.
21+
endpoint.pathname = path;
22+
1823
return endpoint;
1924
};

0 commit comments

Comments
 (0)