Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

29 lines (26 sloc) 0.72 kB
class window.ReducesUrls
constructor: ->
@URL_REGEX = ///
(.*):// #protocol
([^:\?]*) #host
(?::([\d]*))? #[port]
(/[^\?]*)? #[path]
(?:\?(.*))? #[query string]
///
reduce: (url) ->
components = url.match(@URL_REGEX)
{
protocol: components[1],
host: components[2],
port: parseInt(components[3]) || 80
path: components[4],
queryString: components[5],
params: this._parameterize(components[5])
}
_parameterize: (queryString) ->
params = {}
if queryString then _(queryString.split('&')).each((field) ->
pair = field.split('=')
params[pair[0]] = pair[1] || null
)
params
Jump to Line
Something went wrong with that request. Please try again.