[MetaCPAN] GET-ing a module by name Case-Insensitively

Ævar Arnfjörð Bjarmason avarab at gmail.com
Sat Jun 20 14:51:27 GMT 2015


Are CPAN modules themselves case-insensitive? I wonder if PAUSE allows
foo::bar and FOO::BAR.

I doubt that such conflicting modules exists though, but it's worthwhile to
consider what this proposed metacpan API should do in the event of a
collision.
On 20 Jun 2015 4:47 pm, "SundaraRaman R" <sundaryourfriend at gmail.com> wrote:

> Hi,
>
> I'd like to GET data on a module by its name, similar to what the
> /module/Module::Name endpoint does, except I would like to be able to
> specify the Module::Name as module::name or Module::name, etc. What
> would the easiest way to do this be?
>
> The usecase is, I'm hacking on the MetaCPAN Instant Answer on DuckDuckGo
> (eg: https://duckduckgo.com/?q=metacpan+LWP%3A%3AUserAgent), which
> currently uses the /module/Module::Name form of API call internally.
> This gives the user some information about the current version of the
> module, as extracted from the API. It works if the user enters the
> module's name in the exactly correct case, but even a single letter
> being incorrect in case (eg: LWP::Useragent) leads to no result from the
> API. I'd like to change this so that it works whatever case the user
> enters the module name is in.
>
> I noticed that there is a module.name.lowercase field, and got as far as:
>
> $ curl http://api.metacpan.org/v0/module/ -d'
> {
> "filter": { "bool": { "must": [ { "term": { "module.name.lowercase":
> "lwp::useragent" }}, {"match": {"status": "latest"}} ] } }
> }'
>
> which seems to work, but I'm unsure on (a) whether there is a simpler
> way of achieving this (b) whether the above would be sufficient to
> replicate what the /module/ endpoint does i.e. reliably getting the
> latest version of the module.
>
> An additional constraint (and further reason a simpler solution would be
> appreciated) is that the Instant Answers (AFAICT) support making only
> GET requests (without a BODY), no POSTs. So I believe the above would
> have to become a big encoded "?source" abomination if this was indeed
> the simplest way to achieve this. I'm hoping that this is not the case!
>
> Cheers,
> Sundar
>
> _______________________________________________
> MetaCPAN mailing list
> MetaCPAN at lists.scsys.co.uk
> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/metacpan
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/metacpan/attachments/20150620/0a86eec9/attachment.htm>


More information about the MetaCPAN mailing list