According to Google's Closure Compiler URI.js is compiled down to 11.81KB (3.38KB gzipped)
Including punycode.js and IPv6.js you get 15.03KB (4.87KB gzipped)
added your link to the alternatives section in README.md
So the current behaviour is to turn "?&foo=bar&&foo=bar" into "?foo=bar". I've coded a few client-side scripts where removal of unneeded ampersands was useful, but at the same time I needed to keep both repeated name-value pairs (for more advanced form submissions).
I would suggest making normalizeSearch less destructive - i.e. only targeting the unused question mark and ampersands - and splitting the name-value pair deduplication into a separate method.
Github has a nice little feature called issue tracking. Feel free to post your thoughts there. I'd be happy to figure something out. URI.js wasn't intended to limit anyone in what they were trying to do. It just never occured to me that ?foo=bar&foo=bar could be intentional.
I figured more people understand "jQuery-style" than "fluent interface" / "method chaining". Pretty much like you call a tissue "Kleenex" (or "Tempo" in German).
Do you honestly think I ever thought about my dimwit-no-rocket-science URI.js ending up on hacker news? But, to satisfy hacker news readers, I added the terms "fluent interface" and "method chaining" (while preserving "jQuery-like" for normal folk…)
Not to be dismissive, but I feel that if you're a jQuery user, you shouldn't be calling it jQuery-like|style|whatever suffix either. The purpose of terms like fluent interface is so that we can identify a pattern and speak a common language.
Cool work none the less, I didn't give you props in my original post.
Calling it URI.js is a bit namespace-squatty, no? Also, calling everything after the ? the search is a little weird. I used http://code.google.com/p/jsuri/ to build it up on PlaceSteal.
According to the docs[1], search() is an alias of query(). They should use query instead of search, atleast on the landing page. Also, they should put hash() method on the homepage too, I thought they forgot to implement it.
"search" is the term for "query string" used throughout javascript. I prefer "query" (as in "query string"). I use query(), but made search() available to those, who are used to window.location.search
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.
What I would do for JSAN to be all it could have been :-/
One of the things I found building up the PlaceSteal magical library was I needed an actual build/compilation step for turning the various external Javascript libraries I had in to one that would happily go through the Google compiler.
This included a whole bunch of hand-added patches for - for example - moving object-key specification in to one of dot notation or []notation. There were also a bunch of random patches to make things do what I wanted them to do, that didn't seem to be easily done via subclassing or poking around on the insides.
I'm pretty worried about the consequences when I have to upgrade one of the constituent libraries.
I've been working on one as I've got something of a hobby of "collecting" JS libraries - http://resjs.com
It's JSON powered similar to microjs.com (a great site, just not all inclusive) and I've still just got some work to go in terms of adding all the data I've got collected. If there's any interest, I could throw it up on Github and accept contributions to the data.
(One thing that may not be clear at this stage is that each lib will be tagged by license, dependencies, link to source code and/or documentation depending on availablility and have a short description)
What is it with these giant fonts? Why the useless scrolling when you could fit three times the information on one screen? I see this nonsense all over the place...
what is really needed is a good and well documented/tested javascript library for parsing and comparing URLs
I have a bunch of functions (parse_params, get_host, etc.) across a number of projects and always find new bugs with weird URLs that are out in the wild.
yes - thank you! I will take a look at it this weekend and if I have anything in my set of functions that isn't there and might be useful I will submit a pull request.
Tnx, I knew about those, I am currently building the fronted for the Solr powered search engine (adding/removing facets from the url) and sometimes it gets pretty messy.
I was hoping there are some existing resources before I start porting this...
Funny… URI.js is more or less a port of my PHP URL class. Zend Framework has one. look at https://gist.github.com/1499238 to get you started. (Not a chainable API and not as powerful as URI.js either). The path resolving can be taken from the code I wrote for Smarty a couple of months ago: http://code.google.com/p/smarty-php/source/browse/trunk/dist... - lemme know if/when/how you're done… interested in using the PHP version myself ;)
It is dual-licensed, MIT and GPL. Choose the MIT License to do what the fk you like. Choose the GPL License if you're building some GPL software yourself, and need all the components to be GPL-licensed as well. Maybe have a look at http://en.wikipedia.org/wiki/Multi-licensing
source: https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/reso...
tests: https://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/test...
Been meaning to make a Github repo for this. Any interest?