URL Editor

On a few occasions recently I’ve had to deal with long URLs, or more accurately, URLs with long querystrings. Each time it was a chore: strings that are a few hundred characters in length are unwieldy, hard to read and tricky to edit. So I decided to make my life easier and build a tool.

This URL is the kind of thing one encounters when working with Web Map Services:

http://terraservice.net/ogcmap.ashx?SERVICE=WMS&REQUEST=GetMap&VERSION=1.1.1&LAYERS=DRG&FORMAT=image/gif&SRS=EPSG:4326&BBOX=-124.1,41.2,-123.9,41.4&WIDTH=300&HEIGHT=300

It returns a geographic map image based upon the name/value pairs passed in the querystring. Google Charts work in a similar way:

http://chart.apis.google.com/chart?cht=lc&chd=s:cEAELFJHHHKUju9uuXUc&chco=76A4FB&chls=2.0,0.0,0.0&chs=200×125&chg=20,50,3,3,10,20&chxt=x,y&chxl= 0:|0|1|2|3|4|5|1:|0|50|100

To tackle such long URLs I’ve developed the boringly-named URL Editor.

Find it here: http://gingerbbm.com/urleditor

It’s a pretty simple JavaScript application (using Prototype and Scriptaculous) whose main purpose is to split the long querystring of a URL into its constituent name/value pairs in order to dramatically improve legibility. Paste a URL into the main box, click Split, and the name/value pairs appear below:

urleditor01

Once a URL has been split, any edits to the individual values are immediately applied to the main URL, and vice versa.

The Encode and Decode buttons attempt to encode/decode any relevant values that exist.

urleditor02

Click Open to open the URL in its current state in a new window/tab. And Reset resets the whole page.

Reordering of name/value pairs is achieved by dragging them, and you can add and delete them by clicking the relevant buttons.

Bugs

It wouldn’t be hard to trip the application up. The key to it all is the question mark character that denotes the start of a querystring. If you’re not interested in ever opening the URL you can simply start typing into the main box, e.g. “?a=1”, and the name/value pairs will appear.

Names

So, “URL Editor” is a fairly sober moniker, but it was the best of a bad bunch, and being a pretty good description of what it does I decided to go with it.

  • U.R.[NOT HEL]L.
  • URL Manager
  • URL Splitter
  • Querystring Dechunker
  • Any ideas?

And Finally

I’ve tried it out in FF3, IE8, Safari 3 and Opera 9 on XP and it’s all good. It also appears to work in FF3 and Safari 3 on the Mac. Not tried it on Chrome yet, but I don’t expect any surprises. For me it’s been fairly robust, and a useful tool in my arsenal. I hope others find it useful.

🙂

One thought on “URL Editor

Leave a Reply