Skip to content

Commit

Permalink
#14 match a path in respect of serialier extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Khabibullin committed Jun 10, 2015
1 parent 126cb5f commit 15599b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Raisin/Routes/Endpoint.pm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ sub _build_regex {
"(?<format>\.${ \$self->api_format })?";
}
else {
'(?<format>\.\w+)?';
my $se = join '|', Raisin::Util::valid_extensions();
"(?<format>(?:\.(?:$se))?)?";
}
};

Expand All @@ -65,7 +66,7 @@ sub _rep_regex {

for ($switch) {
if ($_ eq ':' || $_ eq '?') {
$r = $a . ($self->check->{$token} // '[^/.]+') . $b;
$r = $a . ($self->check->{$token} // '[^/]+?') . $b;
}
if ($_ eq '*') {
$r = $a . '.+' . $b;
Expand Down
5 changes: 5 additions & 0 deletions lib/Raisin/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ my %SERIALIZERS = (

text => 'text',
txt => 'text',

plain => 'text',
);

sub valid_extensions {
keys %SERIALIZERS;
}

sub detect_serializer {
my $type = shift;
return unless $type;
Expand Down

0 comments on commit 15599b7

Please sign in to comment.