Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
denishowe committed Aug 3, 2024
1 parent f40ba84 commit 54625ab
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
14 changes: 7 additions & 7 deletions Foldoc.pm
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ sub check_redirect

s|^/||; # Drop normal initial /

# Drop extra initial "/"s (except /dev/null) and redirect
# Test: http://foldoc.org//Fairchild
# Test: http://foldoc.org/%2fdev%2fnull
# Drop extra initial "/"s and redirect (except /dev/null)
s|^/+([^d])|$1| && return 1;

# Drop trailing /s except "/", "s///"
Expand Down Expand Up @@ -411,12 +409,14 @@ sub target_entry

sub anchor
{
local ($_) = @_; # $_ used for URL
local ($_) = @_; # $_ used for URL

my $label = text2html($_); # Visible string
s/\n/ /g;
$_ = html2text($_); # Restore "&" etc.
$_ = "/" . text2url($_); # Encode as URL
s/\n/ /g; # Cross-ref may include line break
$_ = html2text($_); # Restore "&" etc.
$_ = text2url($_); # Encode as relative URL
$_ = "/$_"; # Make host-relative
$_ = "/.$_" if (m|^//|); # "//dev/null" => https://dev/null so hide the "//"
$_ = qq(<a href="$_">$label</a>);

return $_;
Expand Down
2 changes: 1 addition & 1 deletion index.pl
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ sub listneighbors
my ($index) = @_;

my ($len, @a) = 0;
# Add term after, before, 2 after, 2 before, ...
# Add term after, before, 2 after, 2 before, etc. until string fills width
for (my $offset = 0; $len < 60; $offset = ($offset > 0 ? 0 : 1) - $offset)
{
my $i = $index+$offset;
Expand Down
4 changes: 4 additions & 0 deletions sink
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
# Windows: C:\Windows\System32\unison.exe

export UNISON=C:/Users/denis/Documents/Tech/Unison/home

# Stop Git bash (mingw) prepending "C:/Program Files/Git" to paths
export MSYS_NO_PATHCONV=1

u="unison foldoc"
$u -batch || $u
ssh -l denis foldoc make --directory=/var/www/foldoc.org
Expand Down
11 changes: 6 additions & 5 deletions t/basic.t
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
use TAP::Harness;
use Test::More tests => 24;
use Test::More tests => 26;
use lib "../lib";
use Test::Web; # ~/Projects/Perl/Test

# Windows: run under cmd, not bash
# cpan install TAP::Harness
# cd foldoc && prove

# Windows: run under cmd, not bash
# cd Projects\FOLDOC\foldoc & cls & prove

$ENV{RUN}++ or TAP::Harness->new->runtests(<*.t>);

Expand Down Expand Up @@ -42,10 +43,10 @@ $t->get_ok("/contents/music.html", "music subject")
$t->get_ok("/?query=foo&action=Search", "legacy query param", 301)
->header_is(Location => $t->absolute("/foo"), "Query param redirect");

# Test: http://foldoc.org//Fairchild
$t->redirects("//Fairchild", "/Fairchild", "Query starts with /");

# Test: http://foldoc.org/%2fdev%2fnull
$t->get_ok("//dev/null", "Term starts with /")
->contains("<h2>/dev/null</h2>");

# Entry with image

Expand Down

0 comments on commit 54625ab

Please sign in to comment.