Compare commits

...

2 commits

Author SHA1 Message Date
worm a17f790832 added simple tests for -protocol 2023-11-15 10:41:48 -08:00
worm 62810c405a add barebones test skeleton 2023-11-15 10:15:55 -08:00
2 changed files with 18 additions and 1 deletions

View file

@ -3,7 +3,7 @@ use Libarchive::Filter :gzip;
my $starts-with-protocol = rx:i/ ^https? '://'/; my $starts-with-protocol = rx:i/ ^https? '://'/;
sub fix-protocol($url) is export { sub fix-protocol(Str $url) is export {
return "http://" ~ $url unless $url ~~ $starts-with-protocol; return "http://" ~ $url unless $url ~~ $starts-with-protocol;
return $url; return $url;

17
t/01-basic.rakutest Normal file
View file

@ -0,0 +1,17 @@
use v6.d;
use Humming-Bird::Core;
use Test;
# Local libs
use lib 'lib';
use Hyperlink-Redirect;
use Hyperlink-Redirect::Helpers;
plan 2;
ok fix-protocol("seriousbusiness.international") eq "http://seriousbusiness.international", \
"fix-protocol fixes bare domains correctly"\
or diag "\nfix-protocol should return the same string with 'http://' prefixed if protocol isn't specified";
ok fix-protocol("https://www.seriousbusiness.international") eq "https://www.seriousbusiness.international",\
"fix-protocol does not mangle correctly formatted domains"\
or diag "\nThe URL should remain unchanged when the protocol is specified";