| 1 | # | ||
| 2 | # Copyright (c) 2014-2019 Christian Jaeger, copying@christianjaeger.ch | ||
| 3 | # | ||
| 4 | # This is free software, offered under either the same terms as perl 5 | ||
| 5 | # or the terms of the Artistic License version 2 or the terms of the | ||
| 6 | # MIT License (Expat version). See the file COPYING.md that came | ||
| 7 | # bundled with this file. | ||
| 8 | # | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | FunctionalPerl::Htmlgen::UriUtil | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | =head1 DESCRIPTION | ||
| 17 | |||
| 18 | |||
| 19 | =head1 NOTE | ||
| 20 | |||
| 21 | This is alpha software! Read the status section in the package README | ||
| 22 | or on the L<website|http://functional-perl.org/>. | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | package FunctionalPerl::Htmlgen::UriUtil; | ||
| 27 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 28 | 3 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 29 | 3 | ▶ | use warnings FATAL => 'uninitialized'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 30 | 3 | ▶ | use experimental "signatures"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 31 | |||
| 32 | 3 | ▶ | use Exporter "import"; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 33 | |||
| 34 | 3 | our @EXPORT = qw(); | |
| 35 | 3 | our @EXPORT_OK = qw(uri_add URI_is_internal); | |
| 36 | 3 | our %EXPORT_TAGS = (all => [@EXPORT, @EXPORT_OK]); | |
| 37 | |||
| 38 | 3 | ▶ | use FP::Docstring; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 39 | 3 | ▶ | use Chj::TEST; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 40 | 3 | ▶ | use URI; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 41 | |||
| 42 | 4 | ▶ | sub uri_add ($base, $rel) { |
|
Subroutine
uri_add: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 43 | 4 | __ '($basestr,$relstr) -> $str ' . '-- (via URI.pm)'; | |
| 44 | 4 | URI->new($rel)->abs(URI->new($base)) . "" | |
| 45 | } | ||
| 46 | |||
| 47 | 1 | ▶ | TEST { uri_add "http://bar.com/baz/", "/zoo#hm" } "http://bar.com/zoo#hm"; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 48 | 1 | ▶ | TEST { uri_add "http://bar.com/baz/", "zoo" } "http://bar.com/baz/zoo"; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 49 | 1 | ▶ | TEST { uri_add "http://bar.com/baz", "zoo" } "http://bar.com/zoo"; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 50 | 1 | ▶ | TEST { uri_add "http://bar.com/baz/#ax", "#bx" } "http://bar.com/baz/#bx"; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 51 | |||
| 52 | # Instead of monkey-patching into the URI package, use a local | ||
| 53 | # name. (We're in need of lexical method definitions!) | ||
| 54 | 0 | ▶ | sub URI_is_internal($self) { |
|
Subroutine
URI_is_internal: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 55 | 0 | not defined $self->scheme | |
| 56 | } | ||
| 57 | |||
| 58 | 3 | 1 | |