From 04504393b53ace3a7a1e4ac1fa764a93d96a4259 Mon Sep 17 00:00:00 2001 From: JJ Nistico Date: Tue, 4 Feb 2025 08:06:42 -0800 Subject: [PATCH 1/3] percent encode endpoint path --- src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 2fac4c6..eeb21d4 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,6 +14,7 @@ export const get_firestore_endpoint = ( const allPaths = ['v1', 'projects', project_id, 'databases', '(default)', 'documents', ...paths]; const path = allPaths.join('/') + suffix; - const endpoint = new URL(path, FIRESTORE_ENDPOINT); + const endpoint = new URL(FIRESTORE_ENDPOINT); + endpoint.pathname = path; return endpoint; }; From 6818e004c194e3536da4f0629432da988b2903d4 Mon Sep 17 00:00:00 2001 From: Alex Iglesias Date: Wed, 5 Feb 2025 12:07:33 +0100 Subject: [PATCH 2/3] chore: document changes --- src/utils.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils.ts b/src/utils.ts index eeb21d4..2716cc0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -15,6 +15,10 @@ export const get_firestore_endpoint = ( const path = allPaths.join('/') + suffix; const endpoint = new URL(FIRESTORE_ENDPOINT); + + // We assign the pathname after instanciating the URL to ensure any hashes are encoded as part of the patname. + // This is done to support use cases where users have hashes in their document IDs. endpoint.pathname = path; + return endpoint; }; From 9bcd6c3f953b915beff9a52df685235d42a00888 Mon Sep 17 00:00:00 2001 From: Alex Iglesias Date: Wed, 5 Feb 2025 12:08:11 +0100 Subject: [PATCH 3/3] chore: added changeset --- .changeset/polite-ladybugs-begin.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/polite-ladybugs-begin.md diff --git a/.changeset/polite-ladybugs-begin.md b/.changeset/polite-ladybugs-begin.md new file mode 100644 index 0000000..bed652f --- /dev/null +++ b/.changeset/polite-ladybugs-begin.md @@ -0,0 +1,5 @@ +--- +'fireworkers': patch +--- + +fix: support document IDs that contain hashes