Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the URL extraction from in-html CSS by replacing regex-based extraction with a dedicated CSS parser, and it adds comprehensive tests for various CSS URL patterns.
- Replaces regex extraction in html.go with a call to a new CSS() function.
- Adds a new css.go file implementing the CSS parsing logic.
- Introduces css_test.go to thoroughly validate CSS URL extraction behavior.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| internal/pkg/postprocessor/extractor/html.go | Removed regex extraction and replaced with CSS() function call |
| internal/pkg/postprocessor/extractor/css_test.go | Added tests covering various CSS URL extraction scenarios |
| internal/pkg/postprocessor/extractor/css.go | Introduces the new CSS parser functions and helper methods |
| go.mod | Updated dependency to github.com/tdewolff/parse/v2 v2.8.1 |
Comments suppressed due to low confidence (1)
internal/pkg/postprocessor/extractor/css.go:226
- [nitpick] The empty else block can be removed as it does not add any functionality and only clutters the code.
else { }
NGTmeaty
previously approved these changes
Jun 3, 2025
NGTmeaty
left a comment
Collaborator
There was a problem hiding this comment.
Looks great! Thank you for your contribution! This should massive improve our extraction!
NGTmeaty
approved these changes
Jun 3, 2025
NGTmeaty
left a comment
Collaborator
There was a problem hiding this comment.
Looks great. Thank you for the improvements here and great job! I can't wait to see the rest of the CSS PRs come through! They will be extremely impactful for Zeno!
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.
#323
The most complete golang css parsing library I've found is https://github.com/tdewolff/parse/, but it returns the entire token as is, for example, if you let it to parse
uRl( "http://a\"b\e9 c" ), it will just return a data structure like:{TokenType: URLToken, Data: []byte(`uRl( "http://a\"b\e9 c" )`) }and won't parse and return the actual value (
http://a"b茅c) for you.Therefore, I wrote a small parser function parseStringOrURLTokenData() to extract value from token data.