Get simple methods to manipulate url parts
Author: 1174557?v=3 yllieth

Angular URL parser

Angular service to get simple methods to manipulate url parts




Once the lib is downloaded, add a reference in your index.html


In your Gemfile, add the following line: ruby gem 'angular_url_parser_rails'

In your application.js, add the following line: //= require angular-url-parser


  • getProtocol([string] url): string : Return the protocol of the given url - Example: "http:", "https:", ...
  • getHost([string] url): string : Return the host of the given url (without port) - Example: "", "localhost", ...
  • getHostname([string] url): string : Return the hostname of the given url (with port) - Example: "", "localhost:3000", ...
  • getPort([string] url): string : Return the port of the given url - Example: "", "3000", ...
  • getRoute([string] url): string : Return the main parts of the given url
  • getRouteAttributes([string] url): array : Return the list of parts of the given url
  • getQuerystring([string] url): string : Return the part of the given url with options
  • getOption([string] param, [string] url): object|string : Return a specific option in the url's options, or all options in an object
  • getHash([string] url): string : Return the hash of the given url
  • parse([string] url): object : Return parsed url in an object: ```json // urlParser.parse('http://localhost:3000/models?sort=asc#quantiles')

    { "protocol": "http:", "host": "localhost:3000", "hostname": "localhost", "port": "3000", "pathname": "/models", "search": "?sort=asc", "searchObject": { "sort": "asc" }, "hash": "quantiles" } ```


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
comments powered by Disqus
This page was last updated almost 2 years ago.