Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Adds support forHTAB as well asSP as whitespace separators incontent-type headers#53

Open
rg2011 wants to merge1 commit intojshttp:master
base:master
Choose a base branch
Loading
fromrg2011:fix/support-htab

Conversation

rg2011
Copy link

@rg2011rg2011 commentedJan 28, 2024
edited
Loading

Fixes issue#52. Notes:

  • The fix applies to bothtypeis andtypeis.is, instead of justtypeis.

    This is becausetypeis.is can receive a req-like or res-like object (this behaviour is undocumented buttested). I wanted to avoid situations wheretypeis(req, ...) would work buttypeis.is(req, ...) would not.

  • The fix breaks backward compatibility in that, previously,typeis would fail if the content-type parameters were not properly formatted. But, after this PR, it will just ignore them.

    i.e. previously, this would returnfalse:

    typeis.is('application/json; charset:utf-8', 'json') // Notice the ":" instead of "=" in charset

    But after this PR, it will return"json".

    This behaviour was documented (...If theContent-Type header is invalid...):

    type-is/README.md

    Lines 35 to 38 in7d19b7a

    Checks if the`request` is one of the`types`. If the request has no body,
    even if there is a`Content-Type` header, then`null` is returned. If the
    `Content-Type` header is invalid or does not matches any of the`types`, then
    `false` is returned. Otherwise, a string of the type that matched is returned.

    But it was not tested in the case of invalid parameters. I am not sure of the best way forward:

    • Keep validating parameters, and make test cases for it,
    • Or update the documentation to clarify that parameters will not be validated.
  • After this PR,media-typer dependency could be upgraded to 1.1.0.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@rg2011

[8]ページ先頭

©2009-2025 Movatter.jp