Giter Site home page Giter Site logo

uri.js's Introduction

Javascript URL parser

URL parsing in javascript. Handles nested arrays and object url params.

Usage

// Parse a uri:
var uri = URI.parse('http://www.nathansplace.co.uk:80/javascript/uri-js/docs/?array[]=one&array[]=two&hash[key]=value#something');

=> {
  protocol: 'http:',
  host: 'www.nathansplace.co.uk',
  port: 80,
  path: ['javascript', 'uri-js', 'docs'],
  params: {
    array: ['one', 'two'],
    hash: {
      key: value
    }
  },
  hash: 'something'
}

// And put it back how you found it...
URI.stringify(uri);

=> 'http://www.nathansplace.co.uk:80/projects/javascript/uri-js/docs/?array[]=one&array[]=two&hash[key]=value#something'

Development

TODO:

  • parse subdomans
  • docs
  • thorough cross browser testing
  • seperate parse and stringify objects out from uri

Testing

Run rake test.

uri.js's People

Contributors

nathamanath avatar kplattret avatar

Stargazers

Greg Price avatar

Watchers

James Cloos avatar  avatar

uri.js's Issues

Values with ampersand break parseParams

Hey, solid plugin. Parameters that have ampersands in them โ€” eg. category=Big%20&%20Tall in the URL โ€” cause Cannot read property 'match' of undefined from valueType's first match conditional.

Looks like the root cause is params = search.split('&'); in parseParams, as it doesn't take into account any other possible ampersands.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.