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 diff --git a/src/utils.ts b/src/utils.ts index 2fac4c6..2716cc0 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -14,6 +14,11 @@ 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); + + // 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; };