Skip to content

Instantly share code, notes, and snippets.

@happyrobots
Created December 19, 2010 18:46
Show Gist options
  • Save happyrobots/747579 to your computer and use it in GitHub Desktop.
Save happyrobots/747579 to your computer and use it in GitHub Desktop.
Return values of request.subdomain

Return Values of request.subdomain

Cases

  • If request.url is 'http://d.a.b.c', request.subdomain returns 'd.a'
  • If request.url is 'http://a.b.c', request.subdomain returns 'a'
  • If request.url is 'http://b.c', request.subdomain returns empty string.
  • If request.url is 'http://c', request.subdomain returns empty string.

Whether port number is used does not affect return values.. of course.

Examples

request.subdomain returns empty string ('').

request.subdomain returns 'www'

request.subdomain returns 'blog'

request.subdomain returns 'blog.my'

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment