RestHelper GET strips off .com when GETting email as parameter with .com address

36 views
Skip to first unread message

Albert Sikkema

unread,
Mar 20, 2012, 7:00:32 AM3/20/12
to lif...@googlegroups.com
Hi All,

I'm using the RestHelper to create a restful service. All works great, however I'm running into a weird thing. When submitting an email via an HTTP GET with a .com domain it strips off the .com in the rest endpoint. Any other domain (.nl for example) works.

function:
case "check" :: "email" :: email :: _ Get _ => {
      println("rest email = " + email)
//logic..
}

when submitting: http://localhost:8080/check/email/testp...@domain.com it prints: "rest email = testperson@domain"
when submitting: http://localhost:8080/check/email/testp...@domain.nl it prints: "rest email = testperson@domain.nl"

I can't see why it behaves differently for .com, I've tried many variations(like .coms), but it only strips off .com somehow. Is this intended behavior? (should I encode the email or something?)

Thanks for your help!

-Albert


Jeppe Nejsum Madsen

unread,
Mar 20, 2012, 7:59:47 AM3/20/12
to lif...@googlegroups.com
On Tue, Mar 20, 2012 at 12:00 PM, Albert Sikkema <a.sik...@gmail.com> wrote:
> Hi All,
>
> I'm using the RestHelper to create a restful service. All works great,
> however I'm running into a weird thing. When submitting an email via an HTTP
> GET with a .com domain it strips off the .com in the rest endpoint. Any
> other domain (.nl for example) works.
>
> function:
> case "check" :: "email" :: email :: _ Get _ => {
>       println("rest email = " + email)
> //logic..
> }
>
> when submitting: http://localhost:8080/check/email/testp...@domain.com it
> prints: "rest email = testperson@domain"
> when submitting: http://localhost:8080/check/email/testp...@domain.nl it
> prints: "rest email = testp...@domain.nl"

>
> I can't see why it behaves differently for .com, I've tried many
> variations(like .coms), but it only strips off .com somehow. Is this
> intended behavior? (should I encode the email or something?)

Have a look at LiftRules.explicitlyParsedSuffixes

/**
* When a request is parsed into a Req object, certain suffixes are
explicitly split from
* the last part of the request URI. If the suffix is contained in
this list, it is explicitly split.
* The default list is: "html", "htm", "jpg", "png", "gif", "xml",
"rss", "json" ...
*/
@volatile var explicitlyParsedSuffixes: Set[String] = knownSuffixes

/Jeppe

Albert Sikkema

unread,
Mar 20, 2012, 8:06:08 AM3/20/12
to lif...@googlegroups.com
Aha! Searched everywhere. Now it makes sense. I guess, for my particular use-case taking out 'com' from the list works. Can't see any harm in that. (is there?)

Thanks a lot for the pointer!
-Albert

Richard Dallaway

unread,
Mar 20, 2012, 8:35:02 AM3/20/12
to lif...@googlegroups.com
I've done this kind of thing in the past:

case Req("check" :: "email" :: email :: Nil, suffix, GetRequest) =>
   val complete_address = if (suffix.isEmpty) email else "%s.%s" format (email,suffix) 
  ("email" -> complete_address): JObject  
     


Regards
Richard

--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

Albert Sikkema

unread,
Mar 20, 2012, 9:10:36 AM3/20/12
to lif...@googlegroups.com
I went with that at first, but since I don't want to have .com split off anywhere I solved it using:
LiftRules.explicitlyParsedSuffixes = Helpers.knownSuffixes &~ (Set("com"))

-Albert
Reply all
Reply to author
Forward
0 new messages