Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Invalid command removal. #268

Merged
merged 2 commits into from
Jun 1, 2022
Merged

Conversation

JimBobSquarePants
Copy link
Member

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following matches the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

This PR does a few things

  • Prevents multiple enumeration of comand keys and removes invalid commands in a single loop.
  • Allows duplicate commands in the URL (avoiding ArgumentException), taking and parsing only the last one. (Duplicates are not counted in cache key generation as that happens following stripping)
  • Update ImageSharp to v2.1.2

@JimBobSquarePants JimBobSquarePants added this to the v2.0.1 milestone May 26, 2022
@JimBobSquarePants JimBobSquarePants requested a review from a team May 26, 2022 12:45
@codecov
Copy link

codecov bot commented May 26, 2022

Codecov Report

Merging #268 (f8fdde6) into main (414abfe) will decrease coverage by 0%.
The diff coverage is 100%.

@@         Coverage Diff         @@
##           main   #268   +/-   ##
===================================
- Coverage    85%    85%   -1%     
===================================
  Files        75     75           
  Lines      2036   2029    -7     
  Branches    298    296    -2     
===================================
- Hits       1741   1735    -6     
  Misses      211    211           
+ Partials     84     83    -1     
Flag Coverage Δ
unittests 85% <100%> (-1%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...Commands/PresetOnlyQueryCollectionRequestParser.cs 100% <100%> (ø)
...Sharp.Web/Commands/QueryCollectionRequestParser.cs 71% <100%> (ø)
.../ImageSharp.Web/Middleware/ImageSharpMiddleware.cs 80% <100%> (-1%) ⬇️
.../Synchronization/RefCountedConcurrentDictionary.cs 72% <0%> (-4%) ⬇️
src/ImageSharp.Web/Commands/CommandCollection.cs 94% <0%> (+8%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b86ae56...f8fdde6. Read the comment docs.

Copy link
Contributor

@brianpopow brianpopow left a comment

Choose a reason for hiding this comment

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

Looks good

@JimBobSquarePants JimBobSquarePants merged commit 52a9fa0 into main Jun 1, 2022
@JimBobSquarePants JimBobSquarePants deleted the js/no-double-enumerate- branch June 1, 2022 14:27
@ronaldbarendse
Copy link
Contributor

Allows duplicate commands in the URL (avoiding ArgumentException), taking and parsing only the last one. (Duplicates are not counted in cache key generation as that happens following stripping)

Can you elaborate how you'd get an ArgumentException, because the following query strings both work and will result in the same parsed commands:

  • ?width=400&height=400&rxy=1,1
  • ?width=400&height=400&rxy=1&rxy=1

This is because StringValues.ToString() joins multiple values as a comma separated string, resulting in the same 1,1 value for the rxy command, not duplicate commands. This is therefore a breaking change in how the command parsing works, as some users might depend on this behavior.

@JimBobSquarePants
Copy link
Member Author

If someone depends on non supported scenarios then that’s their problem. I have no obligation to care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants