Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #68 in support of eslint/eslint#16555.
This solution is a kind of hacky workaround based on #68's comments. It "encodes" all backslash-escaped forward slashes (
'\\' + '/'
) with a backslash and an equivalent unicode character ('\\' + '\\x2F'
).I think it would be much better to work within the PEG grammar in
grammar.pegjs
. Unfortunately, there is no backtracking or other nontrivial regular expression techniques in PEG.js. Expressions liked:[^\/]+
("capture any number of characters other than/
, under the named
") don't have a way I could find to, say, skip past a character like\
.& { predicate }
and! { predicate }
with matchers like"/" d:.+ { ... } "/"
or just"/" d:.+ { ... }
also seemed promising. But then I couldn't figure out how to get it to match non-greedily: i.e. the full/foo\/bar/
instead of just/foo\/
.I don't often work with PEGs and am not confident I didn't miss some obvious technique. I hope someone who's more experienced in these matters will point something out that's more PEG-oriented. 🙂