Hacker News new | comments | show | ask | jobs | submit login

You can do a lot of URI parsing without a library at all -- it's built into the DOM of every browser, even IE6.

  var temp = document.createElemenet('a');
  temp.href = 'http://www.google.com/search?q=foo#blah;
  alert(temp.hostname); // www.google.com
  alert(temp.hash);     // #blah
  alert(temp.protocol); // http:
  alert(temp.search);   // ?q=foo
  temp.search = '?q=baz';
  alert(temp.href);     // http://www.google.com/search?q=baz#blah

  // assuming this is running on http://www.example.com:
  temp.href = '/asdf.html';
  alert(temp.href);     // http://www.example.com/asdf.html

That is noted in README.md of URI.js - you can also find a (very simple) performance comparison here: http://jsperf.com/idl-attributes-vs-uri-js

Does the IDL stuff work in non-browser Javascript (like node.js)?

Node has http://nodejs.org/docs/latest/api/url.html built-in.

URI.js could be really useful for developers building web apps that need to do a lot of URL parsing or manipulation. But developers who only need basic functionality outside of performance-critical loops would probably be better off using built-in functionality.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | Legal | Apply to YC | Contact