Skip to content

Commit

Permalink
renamed scheme_data attribute to data
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Apr 23, 2013
1 parent 8b87105 commit aebb685
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Changes
@@ -1,6 +1,6 @@

3.97 2013-04-23
- Added scheme_data attribute to Mojo::URL.
- Added data attribute to Mojo::URL.
- Improved tests.

3.96 2013-04-22
Expand Down
28 changes: 14 additions & 14 deletions lib/Mojo/URL.pm
Expand Up @@ -10,7 +10,7 @@ use Mojo::Path;
use Mojo::Util qw(punycode_decode punycode_encode url_escape url_unescape);

has base => sub { Mojo::URL->new };
has [qw(fragment host port scheme scheme_data userinfo)];
has [qw(data fragment host port scheme userinfo)];

sub new { shift->SUPER::new->parse(@_) }

Expand Down Expand Up @@ -45,7 +45,7 @@ sub clone {
my $self = shift;

my $clone = $self->new;
$clone->$_($self->$_) for qw(scheme scheme_data userinfo host port fragment);
$clone->$_($self->$_) for qw(scheme data userinfo host port fragment);
$clone->path($self->path->clone);
$clone->query($self->query->clone);
$clone->base($self->base->clone) if $self->{base};
Expand Down Expand Up @@ -89,7 +89,7 @@ sub parse {
}

# Preserve scheme data
else { $self->scheme_data(substr($url, length($proto) + 1)) }
else { $self->data(substr($url, length($proto) + 1)) }

return $self;
}
Expand Down Expand Up @@ -203,7 +203,7 @@ sub to_string {
my $self = shift;

# Scheme data
my $data = $self->scheme_data;
my $data = $self->data;
return join ':', $self->scheme, $data if defined $data;

# Protocol
Expand Down Expand Up @@ -285,6 +285,16 @@ L<Mojo::URL> implements the following attributes.
Base of this URL.
=head2 data
my $data = $url->data;
$url = $url->data('foo')
Data preserved for unknown schemes.
# "sri@example.com"
Mojo::URL->new('mailto:sri@example.com')->data;
=head2 fragment
my $fragment = $url->fragment;
Expand Down Expand Up @@ -313,16 +323,6 @@ Port part of this URL.
Scheme part of this URL.
=head2 scheme_data
my $data = $url->scheme_data;
$url = $url->scheme_data('foo')
Data for unknown schemes.
# "sri@example.com"
Mojo::URL->new('mailto:sri@example.com')->scheme_data;
=head2 userinfo
my $userinfo = $url->userinfo;
Expand Down
18 changes: 9 additions & 9 deletions t/mojo/url.t
Expand Up @@ -118,19 +118,19 @@ is $url->query, '', 'no query';
is $url->fragment, undef, 'no fragment';
is "$url", 'DATA:helloworld123', 'right format';
$url = Mojo::URL->new->parse('mailto:sri@example.com');
is $url->scheme, 'mailto', 'right scheme';
is $url->protocol, 'mailto', 'right protocol';
is $url->scheme_data, 'sri@example.com', 'right scheme data';
is $url->scheme, 'mailto', 'right scheme';
is $url->protocol, 'mailto', 'right protocol';
is $url->data, 'sri@example.com', 'right data';
is "$url", 'mailto:sri@example.com', 'right format';
$url = Mojo::URL->new->parse('foo://test/123');
is $url->scheme, 'foo', 'right scheme';
is $url->protocol, 'foo', 'right protocol';
is $url->scheme_data, '//test/123', 'right scheme data';
is $url->scheme, 'foo', 'right scheme';
is $url->protocol, 'foo', 'right protocol';
is $url->data, '//test/123', 'right data';
is "$url", 'foo://test/123', 'right format';
is $url->scheme('Bar')->to_string, 'Bar://test/123', 'right format';
is $url->scheme, 'Bar', 'right scheme';
is $url->protocol, 'bar', 'right protocol';
is $url->scheme_data, '//test/123', 'right scheme data';
is $url->scheme, 'Bar', 'right scheme';
is $url->protocol, 'bar', 'right protocol';
is $url->data, '//test/123', 'right data';

# Relative
$url = Mojo::URL->new('foo?foo=bar#23');
Expand Down

0 comments on commit aebb685

Please sign in to comment.