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

suggestion for behaviour of mimetype_isa #30

Open
doriantaylor opened this issue Sep 27, 2017 · 0 comments
Open

suggestion for behaviour of mimetype_isa #30

doriantaylor opened this issue Sep 27, 2017 · 0 comments

Comments

@doriantaylor
Copy link

Hello,

I found myself writing the same mimetype_really_isa function over and over again, such that I eventually made it into a module of its own (a Role, actually):

https://github.com/doriantaylor/p5-role-mimeinfo/blob/master/lib/Role/MimeInfo.pm#L80

The code changes the behaviour of mimetype_isa the following ways:

  • mimetype_isa('a/b', 'a/b') now returns true
  • mimetype_isa('a/b.noncanon', 'a/b') now returns true
  • mimetype_isa('a/b', 'x/y.noncanon') now returns true (assuming a/b is a x/y to begin with)
  • mimetype_isa('a/b') will return the entire set of ancestor types (including a/b and all paths up to application/octet-stream)

The purpose was to create a mimetype_isa that would take as wide a range of input as possible and didn't need any finessing first, which I found myself repeatedly doing with my own ad-hoc mimetype_really_isa function.

So, I wrapped it up into a Role. It really shouldn't be a Role. Indeed the code should probably be in this module.

But, of course, the behaviour is subtly different, so I'm not about to do a fork/clone/PR without talking to you first.

Thoughts?

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

No branches or pull requests

1 participant