Skip to content

Instantly share code, notes, and snippets.

@avian2
Created February 18, 2012 19:02
Show Gist options
  • Select an option

  • Save avian2/1860669 to your computer and use it in GitHub Desktop.

Select an option

Save avian2/1860669 to your computer and use it in GitHub Desktop.
HTTPS Everywhere for Net::Zemanta::Suggest
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