Skip to content

Instantly share code, notes, and snippets.

/clone.diff Secret

Created August 16, 2014 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7ef516a683456225676c to your computer and use it in GitHub Desktop.
Save anonymous/7ef516a683456225676c to your computer and use it in GitHub Desktop.
diff --git a/lib/Mojo/Parameters.pm b/lib/Mojo/Parameters.pm
index 46c48a9..b79fda9 100644
--- a/lib/Mojo/Parameters.pm
+++ b/lib/Mojo/Parameters.pm
@@ -32,8 +32,8 @@ sub clone {
my $self = shift;
my $clone = $self->new->charset($self->charset);
- if (defined $self->{string}) { $clone->{string} = $self->{string} }
- else { $clone->params([@{$self->params}]) }
+ if (defined $self->{string}) { $clone->{string} = $self->{string} }
+ else { $clone->{params} = [@{$self->params}] }
return $clone;
}
diff --git a/lib/Mojo/URL.pm b/lib/Mojo/URL.pm
index e025194..3420b49 100644
--- a/lib/Mojo/URL.pm
+++ b/lib/Mojo/URL.pm
@@ -44,9 +44,11 @@ sub clone {
my $self = shift;
my $clone = $self->new;
- $clone->$_($self->$_) for qw(scheme userinfo host port fragment);
- $clone->path($self->path->clone)->query($self->query->clone);
- $clone->base($self->base->clone) if $self->{base};
+ my @keys = qw(scheme userinfo host port fragment);
+ @$clone{@keys} = @$self{@keys};
+ $clone->{path} = $self->path->clone;
+ $clone->{query} = $self->query->clone;
+ if (my $base = $self->{base}) { $clone->{base} = $base->clone }
return $clone;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment