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

Content type with profile not matching as expected #44

Closed
wmurphyrd opened this issue May 5, 2020 · 4 comments
Closed

Content type with profile not matching as expected #44

wmurphyrd opened this issue May 5, 2020 · 4 comments
Labels

Comments

@wmurphyrd
Copy link

Version 1.6.18

typeIs.is('application/ld+json; profile="https://www.w3.org/ns/activitystreams"', ['application/ld+json; profile="https://www.w3.org/ns/activitystreams"'])

Evaluates to false. It seems to use different normalization methods for value and type

@dougwilson
Copy link
Contributor

dougwilson commented May 5, 2020

This is because what you provided as the types argument is not valid. You can find the list of allowed strings in that array in the documentation here: https://github.com/jshttp/type-is#typeisismediatype-types

@dougwilson
Copy link
Contributor

There is an open issue #14 to support parameters in the types argument, which I think is what you're asking to support.

@wmurphyrd
Copy link
Author

Ah thanks. I'm just trying to implement this W3 spec. I'm sure It will work fine without specifying the profile in my types list

@dougwilson
Copy link
Contributor

Gotcha, makes sense. So yes, this library doesn't let you match on the parameters. The only way you can do it currently is to include the content-type library to get the library:

var contentType = require('content-type')
var typeis = require('type-is')

// ... later on

if (typeis(req, 'application/ld+json') && contentType.parse(req).parameters.profile === 'https://www.w3.org/ns/activitystreams') {
  // accepts that specific thing
}

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

No branches or pull requests

2 participants