diff options
author | Ryan Kereliuk <ryker@ryker.org> | 2022-11-02 08:41:50 -0700 |
---|---|---|
committer | Olaf Alders <olaf@wundersolutions.com> | 2022-11-02 13:02:18 -0400 |
commit | 8c99f81cb5acd9923b7c71171d5050eb319b6262 (patch) | |
tree | 5cd2fc3fa7318c3f80d425fe5f3729bf8a673dcf /lib/URI/sip.pm | |
parent | 25bda781b2fe7f1e38c6bacf84c896428e06ecc2 (diff) | |
download | uri-8c99f81cb5acd9923b7c71171d5050eb319b6262.tar.gz |
Add missing unit test coverage and fix SIP URI to pass tests. Mainly
fixing the params() setter but make the code more readable in general.
Diffstat (limited to 'lib/URI/sip.pm')
-rw-r--r-- | lib/URI/sip.pm | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/lib/URI/sip.pm b/lib/URI/sip.pm index 4aa2cfa..250b905 100644 --- a/lib/URI/sip.pm +++ b/lib/URI/sip.pm @@ -22,37 +22,33 @@ sub authority { my $self = shift; $$self =~ m,^($URI::scheme_re:)?([^;?]*)(.*)$,os or die; - my $old = $2; + my $start = $1; + my $authoritystr = $2; + my $rest = $3; if (@_) { - my $auth = shift; - $$self = defined($1) ? $1 : ""; - my $rest = $3; - if (defined $auth) { - $auth =~ s/([^$URI::uric])/ URI::Escape::escape_char($1)/ego; - $$self .= "$auth"; - } - $$self .= $rest; + $authoritystr = shift; + $authoritystr =~ s/([^$URI::uric])/ URI::Escape::escape_char($1)/ego; + $$self = $start . $authoritystr . $rest; } - $old; + return $authoritystr; } sub params_form { my $self = shift; $$self =~ m,^((?:$URI::scheme_re:)?)(?:([^;?]*))?(;[^?]*)?(.*)$,os or die; + my $start = $1 . $2; my $paramstr = $3; + my $rest = $4; if (@_) { - my @args = @_; - $$self = $1 . $2; - my $rest = $4; - my @new; - for (my $i=0; $i < @args; $i += 2) { - push(@new, "$args[$i]=$args[$i+1]"); + my @paramarr; + for (my $i = 0; $i < @_; $i += 2) { + push(@paramarr, "$_[$i]=$_[$i+1]"); } - $paramstr = join(";", @new); - $$self .= ";" . $paramstr . $rest; + $paramstr = join(";", @paramarr); + $$self = $start . ";" . $paramstr . $rest; } $paramstr =~ s/^;//o; return split(/[;=]/, $paramstr); @@ -62,13 +58,13 @@ sub params { my $self = shift; $$self =~ m,^((?:$URI::scheme_re:)?)(?:([^;?]*))?(;[^?]*)?(.*)$,os or die; + my $start = $1 . $2; my $paramstr = $3; + my $rest = $4; if (@_) { - my $new = shift; - $$self = $1 . $2; - my $rest = $4; - $$self .= $paramstr . $rest; + $paramstr = shift; + $$self = $start . ";" . $paramstr . $rest; } $paramstr =~ s/^;//o; return $paramstr; |