Skip to content

Commit

Permalink
fix js style
Browse files Browse the repository at this point in the history
  • Loading branch information
mjlescano committed Oct 12, 2016
1 parent 7e2662e commit bd97f5c
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/url-builder/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
var urls = {}
const urls = {}

module.exports.register = function urlBuilderRegister (label, path) { urls[label] = path }
module.exports.register = function urlBuilderRegister (label, path) {
urls[label] = path
}

module.exports.for = function urlBuilderFor (label, params) {
var url = urls[label]

if (!url) throw new Error('Unknown label for urlBuilder ' + label)

if (params) {
Object.keys(params).forEach(function (param) {
var pExp = new RegExp(':' + param, 'g')
url = url.replace(pExp, params[param])
})
}

return url
}

0 comments on commit bd97f5c

Please sign in to comment.