#2415 User Info in Email URIs

SlimerDude Thu 7 May 2015

Hi, this ramble is me answering my own question...

I like using URIs as they convey more meaning than simple strings. So I thought I'd try them for email addresses. The Wikipedia entry on URI Schemes has this example breakdown:

.               path
         _________|________
 scheme /                  \
  name  userinfo  hostname       query
  _|__   ___|__   ____|____   _____|_____
 /    \ /      \ /         \ /           \
 mailto:[email protected]?subject=Topic

So I was hoping to use Uri.userInfo to return just that, only I noticed to make it work you need to prefix the URI with // to signify a host:

`[email protected]`.userInfo         // --> null
`mailto:[email protected]`.userInfo  // --> null
`//[email protected]`.userInfo       // --> "micky.mouse"

Digging around further I found this snippet in RFC 3986 section 3.3 which says:

the URI <mailto:[email protected]> has a path of "[email protected]"

And indeed the Fantom URI holds true:

`[email protected]`.path         // --> "[email protected]"
`mailto:[email protected]`.path  // --> "[email protected]"
`//[email protected]`.path       // --> ""

And obviously a path can't also be the user info! So it just goes to show that this URI standards stuff is a bit of a quagmire!

Login or Signup to reply.