File: basic.t

package info (click to toggle)
liburi-normalize-perl 0.002-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 112 kB
  • sloc: perl: 102; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 1,379 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env perl

use Test::More;

use URI;
use URI::Normalize qw( normalize_uri remove_dot_segments );

{
    my @data = qw(
        HTTPS://www.example.com:443/../test/../foo/index.html
        https://WWW.EXAMPLE.COM/./foo/index.html
        https://www.example.com/%66%6f%6f/index.html
        https://www.example.com/foo/index.html
    );
    my $expect = $data[-1];

    is normalize_uri($_), $expect, "$_ normalizes" for @data;
}

{
    my @data = qw(
        HTTPS://www.example.com:443/../test/../foo/index.html
        HTTPS://www.example.com:443/foo/index.html

        https://WWW.EXAMPLE.COM/./foo/index.html
        https://WWW.EXAMPLE.COM/foo/index.html

        https://www.example.com/%66%6f%6f/index.html
        https://www.example.com/%66%6f%6f/index.html

        https://www.example.com/foo/index.html
        https://www.example.com/foo/index.html

        https://www.example.com/..
        https://www.example.com/

        https://www.example.com/.
        https://www.example.com/

        https://www.example.com/foo/..
        https://www.example.com/

        https://www.example.com/foo/.././../../bar/../baz
        https://www.example.com/baz
    );
    my $expect = $data[-1];

    while (my ($start, $expect) = splice @data, 0, 2) {
        is remove_dot_segments($start), $expect, "$start remove_dot_segments works";
    }
}

done_testing;