Skip to content

Commit

Permalink
removed deprecated to_rel method from Mojo::URL
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 14, 2014
1 parent 551a31e commit 9a77561
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 32 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

4.90 2014-03-14
- Removed deprecated to_rel method from Mojo::URL.
- Fixed textarea and title parsing bugs in Mojo::DOM::HTML.

4.89 2014-03-13
Expand Down
32 changes: 1 addition & 31 deletions lib/Mojo/URL.pm
Expand Up @@ -4,8 +4,7 @@ use overload bool => sub {1}, '""' => sub { shift->to_string }, fallback => 1;

use Mojo::Parameters;
use Mojo::Path;
use Mojo::Util
qw(deprecated punycode_decode punycode_encode url_escape url_unescape);
use Mojo::Util qw(punycode_decode punycode_encode url_escape url_unescape);

has base => sub { Mojo::URL->new };
has [qw(fragment host port scheme userinfo)];
Expand Down Expand Up @@ -166,35 +165,6 @@ sub to_abs {
return $abs;
}

# DEPRECATED in Top Hat!
sub to_rel {
deprecated 'Mojo::URL::to_rel is DEPRECATED';
my $self = shift;

my $rel = $self->clone;
return $rel unless $rel->is_abs;

# Scheme and authority
my $base = shift || $rel->base;
$rel->base($base)->scheme(undef);
$rel->userinfo(undef)->host(undef)->port(undef) if $base->authority;

# Path
my @parts = @{$rel->path->parts};
my $base_path = $base->path;
my @base_parts = @{$base_path->parts};
pop @base_parts unless $base_path->trailing_slash;
while (@parts && @base_parts && $parts[0] eq $base_parts[0]) {
shift @$_ for \@parts, \@base_parts;
}
my $path = $rel->path(Mojo::Path->new)->path;
$path->leading_slash(1) if $rel->authority;
$path->parts([('..') x @base_parts, @parts]);
$path->trailing_slash(1) if $self->path->trailing_slash;

return $rel;
}

sub to_string {
my $self = shift;

Expand Down
2 changes: 1 addition & 1 deletion t/pod_coverage.t
Expand Up @@ -10,7 +10,7 @@ plan skip_all => 'Test::Pod::Coverage 1.04 required for this test!'
# DEPRECATED in Top Hat!
my @tophat = (
qw(content_xml get_line replace_content secret text_after text_before),
qw(to_rel to_xml)
qw(to_xml)
);

# False positive constants
Expand Down

0 comments on commit 9a77561

Please sign in to comment.