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

documentation: "keepEscaping" is missing #26

Closed
vemoo opened this issue Apr 22, 2019 · 5 comments · Fixed by #27
Closed

documentation: "keepEscaping" is missing #26

vemoo opened this issue Apr 22, 2019 · 5 comments · Fixed by #27
Labels

Comments

@vemoo
Copy link
Contributor

vemoo commented Apr 22, 2019

I'm not sure if it's a braces or micromatch issue, but

braces("C:/Program Files \\(x86\\)")

returns

[ "C:/Program Files (x86)" ]

losing the escape characters, making

micromatch.parse("C:/Program Files \\(x86\\)")

return the tokens

[
	{
		"type": "bos",
		"value": "",
		"output": ""
	},
	{
		"type": "text",
		"value": "C:"
	},
	{
		"type": "slash",
		"value": "/",
		"output": "\\/"
	},
	{
		"type": "text",
		"value": "Program Files "
	},
	{
		"type": "paren",
		"value": "("
	},
	{
		"type": "text",
		"value": "x86"
	},
	{
		"type": "paren",
		"value": ")",
		"output": ")"
	}
]

vs what I expected and what

picomatch.parse("C:/Program Files \\(x86\\)")

returns

[
	{
		"type": "bos",
		"value": "",
		"output": ""
	},
	{
		"type": "text",
		"value": "C:"
	},
	{
		"type": "slash",
		"value": "/",
		"output": "\\/"
	},
	{
		"type": "text",
		"value": "Program Files \\(x86\\)"
	}
]

Here's some sample code: https://repl.it/repls/SharpStrangeChemistry

@vemoo
Copy link
Contributor Author

vemoo commented Apr 22, 2019

I've realized theres options.unescape but it doesn't seem to do anything in this case.

@jonschlinkert
Copy link
Member

That's not right, this is a bug, and it's inconsistent with how picomatch works. It should allow you to retain escaping. Thank you for reporting it.

@jonschlinkert
Copy link
Member

ah, wait. The option is keepEscaping. I forgot that I used a different option name to allow you to escape one or the other, or both. If both picomatch and braces had the same option name (unescape) for this specifically, you wouldn't be able to control escaping.

Try this:

console.log(braces("C:/Program Files \\(x86\\)", { keepEscaping: true }));

@vemoo
Copy link
Contributor Author

vemoo commented Apr 22, 2019

Yes, that works. Then the documentation should be updated and it should be added to the documentation of micromatch.

@jonschlinkert
Copy link
Member

Then the documentation should be updated and it should be added to the documentation of micromatch.

Agreed! Thanks for reporting this. Want to do a PR?

@jonschlinkert jonschlinkert changed the title it removes escape characters documentation: "keepEscaping" is missing Apr 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants