fix: helper function to strip mime params#1050
Conversation
2200ab0 to
b9ee28c
Compare
|
@kelson42 is the RTD fail because of the rebase or something else that I have to fix? |
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (33.33%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #1050 +/- ##
==========================================
- Coverage 56.31% 56.29% -0.02%
==========================================
Files 101 101
Lines 5031 5036 +5
Branches 2194 2196 +2
==========================================
+ Hits 2833 2835 +2
- Misses 737 738 +1
- Partials 1461 1463 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a small internal helper to normalize MIME types by removing parameters (everything after ;), and uses it when generating the writer “Counter” metadata so downstream tooling (zim-tools) can reliably validate/count articles by base MIME type.
Changes:
- Add
zim::stripMimeParameters()to strip MIME parameters and trim whitespace before the first;. - Apply MIME-parameter stripping in
CounterHandlerbefore incrementing the MIME counter. - Add unit tests covering common and edge-case MIME strings for the new helper.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
test/tooltesting.cpp |
Adds tests for stripMimeParameters() behavior across typical and edge inputs. |
src/tools.h |
Declares the new private helper API. |
src/tools.cpp |
Implements stripMimeParameters(). |
src/writer/counterHandler.h |
Adds <string> include for the std::string counter key type. |
src/writer/counterHandler.cpp |
Normalizes MIME types (strip params) before counting, preventing parameter variants from inflating counts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@kelson42 the RTD fail is fixed, and about the codecov fail, ill need to add an integration test for the uncovered lines: It'll probably be added in src/writer/creator.cpp, but doesn't seem necessary and the partials also seem unnecessary, please confirm. If no more changes are needed, I'll squash again. |
|
@Pranavjeet-Naidu Thank younfor your PR, but I guess you have linked the wrong issue in your PR description!? |
Actually nope. I linked this issue because of your reply in the end over there. You concluded saying we have to strip MIME type paras. Please let me know if there's a better issue to link instead. |
@kelson42 @veloman-yunkan any update on this? I have the test for these lines ready if needed, but please let me know before I proceed. The test just seems like redundant code considering all it does is check for empty. Wouldn't the unit tests written in tooltesting.cpp suffice? |
veloman-yunkan
left a comment
There was a problem hiding this comment.
Please simplify the zim::stripMimeParameters() function and squash all your changes into a single commit.
|
Also this branch must be rebased on main |
Don't mind about codecov failures if they seem dubious. |
0dfc3ff to
c2cb719
Compare
|
@veloman-yunkan I would squash the empty commit as well and force push but I'm worried RTD will break again :( |
veloman-yunkan
left a comment
There was a problem hiding this comment.
Please get rid of the empty commit and don't worry about RTD.
7694255 to
2e481a2
Compare
veloman-yunkan
left a comment
There was a problem hiding this comment.
I would have approved this PR but in the meantime another PR has been merged in this repository so this PR has to be rebased. While doing it please note the new comments. If you choose to address them, please don't create new commits (just amend the only commit of this PR).
2e481a2 to
63f885b
Compare
|
@veloman-yunkan Last review pass... hopefully :) |
There was a problem hiding this comment.
The #include of "../tools.h" should have stayed in src/writer/counterHandler.cpp. It is now included indirectly in a secretive way which explains why compilation doesn't fail. But in general, you shouldn't depend on such luck and must include explicitly the headers on which your code relies.
@Pranavjeet-Naidu Please fix this and we will merge. |
63f885b to
1fc37a3
Compare
It's up right now, thank you for being patient :) |
|
@veloman-yunkan please confirm all good |
veloman-yunkan
left a comment
There was a problem hiding this comment.
Looks good to me and I bet that it should look good to at least 99% percent of those people who are qualified enough to tell if C++ code can look good at all.
Signed-off-by: Pranavjeet-Naidu <pranavjeetnaidu@gmail.com>
1fc37a3 to
21d7594
Compare
Fixes #1000
Basically a helper function that strips MIME-types params.
should fix the article count issue with the regex validation in zim-tools, this in libzim.