fix: screenshot misidentifies relative dot-paths as CSS selectors - #499
Closed
bluzername wants to merge 1 commit into
Closed
bluzername wants to merge 1 commit into
bluzername wants to merge 1 commit into
Conversation
3 tasks done
Collaborator
|
Closing — the codebase has changed significantly since this was opened and this no longer applies to current main. Thanks for the contribution. |
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.
Problem
browse screenshot ./path/to/file.pngfails with CSS parser error because the argument classifier treats any argument starting with.as a CSS class selector. Same problem with.gstack/screenshots/page.png.Absolute paths like
/tmp/file.pngwork fine because they dont start with..Root Cause
In
browse/src/meta-commands.tsline 117, the conditionarg.startsWith('.')catches both CSS selectors (.my-class) and relative file paths (./screenshots/page.png) without distinguishing them.Fix
Added a file path check before the CSS selector check. If an argument contains
/AND ends with an image/pdf extension (.png,.jpg,.jpeg,.webp,.pdf), it is unambiguously a file path and not a CSS selector.This is safe because:
.menu-itemnever contain/(this is not valid CSS).classdont end with.png./test.pngalways contain/and end with extensionThe existing CSS selector detection stays unchanged for everything else - only file paths with
/and image extension get special handling.Testing
Added test case for
./browse-test-dotpath.pngpath (could not run full integration tests locally since Playwright browsers were not installed, but the logic is minimal and deterministic)../path.png-> CSS selector -> parse error./path.png-> file path -> works.gstack/file.png-> CSS selector -> error.gstack/file.png-> file path -> works.my-class-> CSS selector.my-class-> CSS selector (unchanged)/tmp/file.png-> file path/tmp/file.png-> file path (unchanged)Closes #495