File tree Expand file tree Collapse file tree 3 files changed +791
-1021
lines changed Expand file tree Collapse file tree 3 files changed +791
-1021
lines changed Original file line number Diff line number Diff line change 22var url = require ( 'url' )
33var gitHosts = require ( './git-host-info.js' )
44var GitHost = module . exports = require ( './git-host.js' )
5+ var LRU = require ( 'lru-cache' )
6+ var cache = new LRU ( { max : 1000 } )
57
68var protocolToRepresentationMap = {
79 'git+ssh' : 'sshurl' ,
@@ -23,17 +25,15 @@ var authProtocols = {
2325 'git+http:' : true
2426}
2527
26- var cache = { }
27-
2828module . exports . fromUrl = function ( giturl , opts ) {
2929 if ( typeof giturl !== 'string' ) return
3030 var key = giturl + JSON . stringify ( opts || { } )
3131
32- if ( ! ( key in cache ) ) {
33- cache [ key ] = fromUrl ( giturl , opts )
32+ if ( ! cache . has ( key ) ) {
33+ cache . set ( key , fromUrl ( giturl , opts ) )
3434 }
3535
36- return cache [ key ]
36+ return cache . get ( key )
3737}
3838
3939function fromUrl ( giturl , opts ) {
You can’t perform that action at this time.
0 commit comments