Created
September 15, 2015 19:25
-
-
Save Su-Shee/cd283c2c25d952f8dfd8 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
I have a cheap validation regex for UUIDs on routes - mostly to distinguish :stuff | |
my $uuid = qr/[[:xdigit:]]{8}-([[:xdigit:]]{4}-){3}[[:xdigit:]]{12}/; | |
I use it like so: | |
$r->get('/comments/:object' => [ object => $uuid ]) | |
->to('comments#list_by_item'); | |
or, like this: | |
my $fav = $r->under('/favorites/:object/:id' => [ id => $uuid ]) | |
->to('favorites#exist') | |
when I had it like this: | |
my $fav = $r->under('/favorites/:object/:id' => [ object => $uuid, id => $uuid ]) | |
->to('favorites#exist') | |
the second param - never the first - ALWAYS was: | |
[Tue Sep 15 11:37:17 2015] [debug] "9250-" | |
Ok, maybe I used a reserved name or something - but no, renaming didn't help. | |
So I suspected I'm simply breaking the URL lengths - but no, not even close. | |
Then I thought, ah, I'm an idiot, I just already have the wrong URL!! | |
But no, I did not: | |
curl -X GET -H "Content-Type: application/json" http://localhost:5000/annotations/favorites/$ITEMID/$FAVID | |
resolves perfectly fine to: | |
http://localhost:5000/annotations/favorites/e72cecb5-c457-4b37-9250-c260d3a42731/98ccc1bb-e32f-4970-bee0-a4a4b0357473 | |
(Ignore that it's ugly ;) | |
Weirdly, it works here - with something other than UUIDs: | |
my $fol = $r->under('/followers/:user/:follower' => [ user => $user, follower => $user ]) | |
->to('followers#exist') | |
($user being another qr//; thing) | |
That weird change to "9250-" happens only on using $uuid twice. | |
Am I overlooking something totally obvious? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment