-
Notifications
You must be signed in to change notification settings - Fork 11
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
Prefer exact match without parameters to one with extra parameters #36
base: master
Are you sure you want to change the base?
Prefer exact match without parameters to one with extra parameters #36
Conversation
If 'type/subtype' and 'type/subtype;param=1' are supported and 'type/subtype' is accepted, prefer 'type/subtype'.
Hi @suola , and thanks for this PR! |
I'm not sure this is best way of doing this, since it returns different results when using q values. |
mimeparse.py
Outdated
# 1 bonus point if neither has any parameters | ||
if (set(target_params) | set(params)) - {'q'} == set(): | ||
fitness += 1 | ||
|
||
# finally, add the target's "q" param (between 0 and 1) | ||
fitness += float(target_params.get('q', 1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as currently implemented the q has basically no say
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, I fixed this + added a test case for that
Take q into account also when comparing options with same type but different parameters. Change fitness into a list of metrics in decreasing order of precedence. This cleaner than building a floating point value now that a condition is evaluated after `q`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense to me.
I'm not sure regarding the change in api change, but I think it would be ok since I think we plan on releasing v2 so api changes would be ok
We need to rebase this PR now that we moved Speaking of the changes in general, maybe we could just leave the current behavior as-is? @suola btw if you were interested in this in the context of Falcon, this has been fixed by rolling out a different implementation there, see |
If 'type/subtype' and 'type/subtype;param=1' are supported and
'type/subtype' is accepted, prefer 'type/subtype'.