Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ensure document names with _local in them get properly url encoded #342

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jumoel
Copy link

@jumoel jumoel commented Apr 22, 2024

Overview

Fix a bug where a document whose name included _local somewhere would not get properly URL encoded.

Non-replicating documents need to start with _local and not just contain _local. The regular expression testing for this was missing a parenthesis.

Testing recommendations

This will allow documents that have a name both containing characters that need to be URL encoded as well as _local to be properly inserted.

GitHub issue number

Related Pull Requests

Checklist

  • Code is written and works correctly;
  • Changes are covered by tests;
  • Documentation reflects the changes;

test/document.insert.test.js Outdated Show resolved Hide resolved
@@ -316,7 +316,7 @@ module.exports = exports = function dbScope (cfg) {
if (opts.path) {
req.uri += '/' + opts.path
} else if (opts.doc) {
if (!/^_design|_local/.test(opts.doc)) {
if (!/^(_design|_local)/.test(opts.doc)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we test for a slash immediately following _design or _local as well?

Suggested change
if (!/^(_design|_local)/.test(opts.doc)) {
if (!/^(_design|_local)\//.test(opts.doc)) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants