fix(assets-sync): only treat # as a comment at line start or after whitespace#69
Draft
lwshang wants to merge 2 commits into
Draft
fix(assets-sync): only treat # as a comment at line start or after whitespace#69lwshang wants to merge 2 commits into
# as a comment at line start or after whitespace#69lwshang wants to merge 2 commits into
Conversation
…whitespace Previously the `_redirects` and `_headers` parsers cut every line at the first `#`, which corrupted URL fragments such as `/to/#topic` and CSP `report-uri /csp#endpoint`. The new shared `strip_comment` in `lib.rs` matches Netlify's reference parser: a `#` only begins a comment when it sits at the start of the line or is preceded by ASCII whitespace, so a `#` embedded inside a token is preserved. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…rors A bare line number forces users to count down the file to find the bad rule. Embedding the offending line in the error message makes it obvious which entry to fix. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Draft
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
_redirects/_headersparsers cut every line at the first#, which corrupted URL fragments such as/to/#topicin a redirect target orreport-uri /csp#endpointin a CSP header value.strip_commenthelper inassets-sync/src/lib.rsmatches Netlify's reference parser: a#only begins a comment when it sits at the start of the line or is preceded by ASCII whitespace, so a#embedded inside a token is preserved.redirects.rsandheaders.rs._redirects: line 71: expected '<from> <to> <status>' (3 fields), got 2 (source: \/incomplete /target`)`) so users don't have to count lines to find the bad entry.Supersedes #67 (thanks @raymondk for spotting the bug). The token-aware rule is a strict superset of Cloudflare's documented "lines starting with
#" behaviour, so files written for either platform keep working.Test plan
cargo test -p assets-sync— 187 tests pass, including new coverage for: fragment in redirectto, fragment in CSP header value, tab-preceded#, source-line embedded in parse errors, and the 6strip_commentunit tests inlib.rs.cargo clippy -p assets-sync --all-targets -- -D warningsclean.🤖 Generated with Claude Code