Skip to content

Commit

Permalink
add caching to fromUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesherov committed Jun 20, 2017
1 parent 91fb3ad commit 3e376eb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ var authProtocols = {
'git+http:': true
}

var cache = {}

module.exports.fromUrl = function (giturl, opts) {
var key = giturl + JSON.stringify(opts || {})

if (!(key in cache)) {
cache[key] = fromUrl(giturl, opts)
}

return cache[key]
}

function fromUrl (giturl, opts) {
if (giturl == null || giturl === '') return
var url = fixupUnqualifiedGist(
isGitHubShorthand(giturl) ? 'github:' + giturl : giturl
Expand Down

0 comments on commit 3e376eb

Please sign in to comment.