Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2570 from duckduckgo/zaahir/fix-equaldex
Browse files Browse the repository at this point in the history
Equaldex: Fix API call to address redirect
  • Loading branch information
MrChrisW committed Mar 12, 2016
2 parents 79682e0 + 868c99e commit 18b3fe1
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/DDG/Spice/Equaldex.pm
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package DDG::Spice::Equaldex;

# ABSTRACT: LGBT rights by region

use DDG::Spice;
use Locale::Country;
use Locale::Country;

spice is_cached => 1;

spice to => 'http://equaldex.com/api/region?format=json&region=$1&callback={{callback}}';
spice to => 'http://www.equaldex.com/api/region?format=json&region=$1&callback={{callback}}';

triggers startend => "lgbt", "lesbian", "gay", "bisexual", "transgender";
my $guardRe = qr/(rights?|laws?) (in)?\s?/;
Expand All @@ -15,9 +16,9 @@ handle remainder => sub {
if(m/$guardRe/) {
my $country = $';
# Workaround for Locale::Country returning ISO 3166-1 alpha-2 code when using country2code("us(a)")
$country = "united states" if $country =~ /\busa?\b/;
$country = "united states" if $country =~ /\busa?\b/;
# Return full country name if valid
return $country if defined country2code($country);
return $country if defined country2code($country);
# Return country name from ISO 3166-1 alpha-2 code
if(code2country($country, LOCALE_CODE_ALPHA_2)) {
return lc code2country($country, LOCALE_CODE_ALPHA_2);
Expand Down

0 comments on commit 18b3fe1

Please sign in to comment.