Created
February 14, 2010 14:51
-
-
Save zigorou/304078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/URI/Template/Restrict.pm b/lib/URI/Template/Restrict.pm | |
index 22182de..7b93851 100644 | |
--- a/lib/URI/Template/Restrict.pm | |
+++ b/lib/URI/Template/Restrict.pm | |
@@ -9,9 +9,11 @@ use List::MoreUtils qw(uniq); | |
use Unicode::Normalize qw(NFKC); | |
use URI; | |
use URI::Escape qw(uri_escape_utf8); | |
+use URI::Split qw(uri_split uri_join); | |
use URI::Template::Restrict::Expansion; | |
-our $VERSION = '0.03'; | |
+our $VERSION = '0.04'; | |
+our $RE_PATH_NORMALIZE = qr{([^a-zA-Z-._~/])}; | |
__PACKAGE__->mk_ro_accessors(qw'template segments'); | |
@@ -78,6 +80,10 @@ sub process_to_string { | |
sub extract { | |
my ($self, $uri) = @_; | |
+ my @uri_splited = uri_split $uri; | |
+ $uri_splited[2] =~ s|$RE_PATH_NORMALIZE|uri_escape_utf8($1)|gxe; | |
+ $uri = uri_join @uri_splited; | |
+ | |
my $re = join '', map { ref $_ ? '('.$_->pattern.')' : quotemeta $_ } @{ $self->segments }; | |
my @match = $uri =~ /$re/; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment