Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Be less restrictive about mime types
Allow any mime type that contains 'text/plain' or 'perl' in it.
Also, attempt to decode the response based on the given charset,
so ISO-8859-1 should be supported in addition to UTF-8. Closes #17.
  • Loading branch information
MasterDuke17 committed Aug 30, 2016
1 parent b919be5 commit dc40d25
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Whateverable.pm6
Expand Up @@ -172,12 +172,12 @@ method process-url($url, $message) {
return (0, It looks like a URL, but for some reason I cannot download it
~ (HTTP status line is {$response.status-line}).);
}
if $response.field(content-type) ne text/plain; charset=utf-8 {
return (0, It looks like a URL, but mime type is ‘{$response.field(content-type)}
~ while I was expecting ‘text/plain; charset=utf-8’.
~ I can only understand raw links, sorry.);
if not $response.content-type.contains(any(text/plain, perl)) {
return (0, It looks like a URL, but mime type is ‘{$response.content-type}
~ while I was expecting something with ‘text/plain’ or ‘perl’
~ in it. I can only understand raw links, sorry.);
}
my $body = $response.content;
my $body = $response.decoded-content;

$message.reply: Successfully fetched the code from the provided URL.;
return (1, $body)
Expand Down

0 comments on commit dc40d25

Please sign in to comment.