 encodeQueryComponent = (value) ->
     encodeURIComponent(value).replace(/%20/g, '+').replace /%2C/g, ','
 
-generateQuery = (specs, resource, originalUrl) ->
+generateQuery = (specs, resource, originalUrl, path) ->
     query = ''
     queryParts = []
 

            fragment = '#!service-details'
    else if resource == 'unit' and specs.unit != null
        path.push specs.unit
    protocol + path.join('/') + generateQuery(specs, resource, originalUrl) + fragment


getMunicipalityFromGeocoder = (address, language, callback) ->

        addQuery 'radius', specs.radius

    originalUrl = originalUrl.replace /\/rdr\/?/, ''
    if queryParts.length < 1 and path.length < 2
        # This represents the case where the redirect originates from
        # the root URL (no path, no query parameters).  In that case,
        # leave the _rdr parameter out.
        return ''
    queryParts.push '_rdr=' + encodeURIComponent(originalUrl)
    '?' + queryParts.join('&')

getResource = (specs) ->
