         return 'address'
     null
 
-generateUrl = (specs) ->
+generateUrl = (specs, originalUrl) ->
     protocol = 'http://'
     subDomain = languageIdMap[specs.language.id]
     resource = getResource(specs)

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

redirector = (req, res) ->
    specs = extractSpecification(req)
    url = generateUrl(specs)
    res.redirect 301, url
    return


    if resource = 'address'
        addQuery 'radius', specs.radius

    originalUrl = originalUrl.replace /\/rdr\/?/, ''
    queryParts.push '_rdr=' + encodeURIComponent(originalUrl)
    if queryParts.length == 0
        return ''
    '?' + queryParts.join('&')
