apache / couchdb-nano

Nano: The official Apache CouchDB library for Node.js
https://www.npmjs.com/package/nano
Apache License 2.0
651 stars 165 forks source link

nano.head() and "/" (forwardslash) characters #291

Closed leapinweasel closed 2 years ago

leapinweasel commented 2 years ago

I'm failing to use the head() command in documents with "/" in the id. The document exists, but always returns null, as the method does not replace the "/" command with %2F. I tried to escape it myself before passing, and then it does escape the "%" value and still fails to find.

I'm using an older version, I haven't been able to upgrade yet, but I couldn't find anything in recent release notes for this issue.

Expected Behavior

head() method should find documents with IDs containing "/" characters.

Current Behavior

head() always returns null when looking for documents with "/" in the ID.

Possible Solution

Steps to Reproduce (for bugs)

Please note my javascript is not good.

const db = nano.use("mydatabase"); await db.insert({ _id: "TEST/DOC" }); let result = await db.head("TEST/DOC");

Context

Our real world data exists in a system which allows "/" in names. We use couchdb in an integration environment, but can't work with this data.

Your Environment

glynnbird commented 2 years ago

This definitely works fine on the 9.x releases, just tested it :)

leapinweasel commented 2 years ago

Thank you very much!