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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Order and filter processors by supported commands #183

Merged

Conversation

ronaldbarendse
Copy link
Contributor

@ronaldbarendse ronaldbarendse commented Aug 30, 2021

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 fixes issue #182 by ordering and filtering the processors by supported commands.

The biggest change this introduces is not calling the Process(...) method on processors where the Commands collection doesn't contain a parsed command.

@CLAassistant
Copy link

CLAassistant commented Aug 30, 2021

CLA assistant check
All committers have signed the CLA.

@ronaldbarendse
Copy link
Contributor Author

ronaldbarendse commented Aug 30, 2021

I just tested this PR again (with browser caching off) and noticed it always returned -1 as lowest index... Now it uses an intersection of parsed commands and commands supported by the processor, so it really gets the first index of a supported command 馃槃


Because case sensitivity of the commands depend on the comparer used in the dictionary returned by ParseRequestCommands, I've made sure this is also used when stripping out unknown commands and getting the first index for processing. Previously when requesting /imagesharp-logo.png?WIDTH=300 (in Edge, as Chrome seems to be smart and remember the 'correct' URL casing), it stripped out the command, even though the ResizeWebProcessor would use the correct width/value.

It's probably also fine to always use StringComparer.OrdinalIgnoreCase, as that removes the need to get the comparer from the concrete dictionary type...

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. I need to do a thorough review + perf check this but I've made some notes.

@codecov
Copy link

codecov bot commented Oct 1, 2021

Codecov Report

Merging #183 (ab8eecb) into master (b11fe03) will decrease coverage by 0.05%.
The diff coverage is 94.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #183      +/-   ##
==========================================
- Coverage   84.71%   84.65%   -0.06%     
==========================================
  Files          50       50              
  Lines        1426     1440      +14     
  Branches      190      194       +4     
==========================================
+ Hits         1208     1219      +11     
- Misses        164      166       +2     
- Partials       54       55       +1     
Flag Coverage 螖
unittests 84.65% <94.44%> (-0.06%) 猬囷笍

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

Impacted Files Coverage 螖
.../ImageSharp.Web/Middleware/ImageSharpMiddleware.cs 85.92% <0.00%> (酶)
...ageSharp.Web/Processors/WebProcessingExtensions.cs 100.00% <100.00%> (酶)
...p.Web/Middleware/ConcurrentDictionaryExtensions.cs 50.00% <0.00%> (-21.43%) 猬囷笍

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 728997a...ab8eecb. Read the comment docs.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

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

I think you're onto something here but I think we can reduce the workload.

Copy link
Member

@JimBobSquarePants JimBobSquarePants left a comment

Choose a reason for hiding this comment

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

Thanks for your help here @ronaldbarendse I'll get an official release out asap with these changes.

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

Successfully merging this pull request may close these issues.

None yet

3 participants