Alvis-Bags

 view release on metacpan or  search on metacpan

bin/linkRedir  view on Meta::CPAN

#!/usr/bin/perl -w

# No documentation yet except for what is in the $USAGE message
# and comments below.
#
# Uses:
#       take standard linkbag format and eliminate redirects;
#       ignores fragments too

use strict;
use POSIX;
use HTML::Entities;
use Alvis::URLs;
use Getopt::Long;
use Pod::Usage;

# encoding pragmas follow any includes like "use"
use encoding 'utf8';

lib/Alvis/URLs.pm  view on Meta::CPAN

  my $string = shift;
  Encode::_utf8_off($string);
  my $dig = md5_hex($string);
  # print $dig . " \n";
  return substr($dig,0,16);
}

#  URL switches
$Alvis::URLs::nocase = 0;
$Alvis::URLs::noclean = 0;
$Alvis::URLs::keepfrag = 0;

sub CleanURL() {
  if ( !$_[0] ) {
	return undef;
  }
  my $uri = new URI($_[0]);
  if ( ! $Alvis::URLs::keepfrag ) {
    $uri->fragment(undef);
  }
  return $uri->canonical;
}

sub StandardURL() {
  my $inu = shift();
  if ( $Alvis::URLs::nocase ) {
    $inu = lc($inu);
  }
  if ( $Alvis::URLs::noclean == 0 ) {

lib/Alvis/URLs.pm  view on Meta::CPAN

1;

__END__

=head1 NAME

Alvis::URLs - URL and hash standardisation utilities.

=head1 SYNOPSIS

 $Alvis::URLs::keepfrag = 0; # set to keep fragment, default removes
 $cleanurl = &Alvis::URLs::CleanURL($url);
 $Alvis::URLs::nocase = 0;   # set to convert everything to lowercase
 $Alvis::URLs::noclean = 0;  # set to disable use of URI cleaning
 $standardurl = &Alvis::URLs::StandardURL($url);

=head1 DESCRIPTION

Provides an MD5 hashing interface, as well as simple standards for URL cleaning
based on the URI library.



( run in 1.270 second using v1.01-cache-2.11-cpan-b16cb0d3907 )