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):
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.
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 truemimetype_isa('a/b.noncanon', 'a/b')
now returns truemimetype_isa('a/b', 'x/y.noncanon')
now returns true (assuminga/b
is ax/y
to begin with)mimetype_isa('a/b')
will return the entire set of ancestor types (includinga/b
and all paths up toapplication/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-hocmimetype_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?