Created
February 18, 2012 19:02
-
-
Save avian2/1860669 to your computer and use it in GitHub Desktop.
HTTPS Everywhere for Net::Zemanta::Suggest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package Net::Zemanta::Suggest::HTTPS; | |
| use strict; | |
| use base qw( Net::Zemanta::Suggest ); | |
| sub suggest { | |
| my $self = shift; | |
| my $suggestions = $self->SUPER::suggest(@_); | |
| my $links = $suggestions->{'markup'}->{'links'}; | |
| for my $link (@$links) { | |
| my $targets = $link->{'target'}; | |
| for my $target (@$targets) { | |
| $target->{'url'} =~ s/^http:\/\/([^\@:\/]+\.)?(wikipedia\.org\/)/https:\/\/$1$2/; | |
| } | |
| } | |
| return $suggestions; | |
| } | |
| 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment