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

escape() #83

Closed
kakserpom opened this issue Mar 23, 2021 · 2 comments · Fixed by #90
Closed

escape() #83

kakserpom opened this issue Mar 23, 2021 · 2 comments · Fixed by #90

Comments

@kakserpom
Copy link

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/dot-prop/index.js b/node_modules/dot-prop/index.js
index aa9c5bb..57a49b5 100644
--- a/node_modules/dot-prop/index.js
+++ b/node_modules/dot-prop/index.js
@@ -134,5 +134,9 @@ module.exports = {
 		}
 
 		return true;
+	},
+
+	escape(prop) {
+		return prop.replace(/\./g, '\\.')
 	}
 };

This issue body was partially generated by patch-package.

@sindresorhus
Copy link
Owner

A good pull request with docs, tests, and types would be welcome. I think the method should be called escapeKeyPath.

@Richienb
Copy link
Contributor

Richienb commented Sep 7, 2021

To futureproof this, it would be a good idea to segment the path and then reassemble an escaped version from there. Especially with #82.

Richienb added a commit to Richienb/dot-prop that referenced this issue Jan 22, 2022
Fixes sindresorhus#83

Signed-off-by: Richie Bendall <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants