Skip to content

Error on trailing backslash#434

Merged
blakeembrey merged 2 commits intomasterfrom
be/error-backslash
Apr 1, 2026
Merged

Error on trailing backslash#434
blakeembrey merged 2 commits intomasterfrom
be/error-backslash

Conversation

@blakeembrey
Copy link
Copy Markdown
Member

Closes #433. Most straightforward approach that takes minimal bytes.

An alternative might be to re-introduce the consume function that throws an error itself, and tryConsume token by token, but I removed that a while back to reduce bytes and function call overhead. The main difference would come down to the error message, which using a tryConsume style approach would hit the universal error message and print something like Unexpected end at index 9, expected char from:

Unexpected ${token.type} at index ${token.index}, expected ${endType}

I don't think adding the overhead back is worth it in this case, it's simpler to treat it as a one off error to handle.

});

it("should throw on eol backslash in quoted param", () => {
expect(() => parse('/foo/:"bar\\')).toThrow(
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Within quotes are fine to increment the undefined because it's already handling the Unterminated quote error. If we wanted to be extra safe we could add the same error there, but I think it's simpler and clearer to keep the current error message.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 1, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.74%. Comparing base (7f05876) to head (b4baac3).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #434   +/-   ##
=======================================
  Coverage   99.74%   99.74%           
=======================================
  Files           1        1           
  Lines         389      392    +3     
  Branches      148      150    +2     
=======================================
+ Hits          388      391    +3     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@blakeembrey blakeembrey merged commit 9a78879 into master Apr 1, 2026
8 checks passed
@blakeembrey blakeembrey deleted the be/error-backslash branch April 1, 2026 19:30
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.

Bug: Trailing backslash in path injects literal "undefined" into token value

1 participant