Skip to content

Commit

Permalink
adding support for install url targeting an exact version
Browse files Browse the repository at this point in the history
  • Loading branch information
soldair committed Jun 3, 2013
1 parent 15224d0 commit 154670a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,13 @@ module.exports = function(config,cb){
var s = Date.now();

// support modulename/version
var targetVersion;

if(data.module.indexOf('/') > -1) {
var parts = data.module.split('/');
if(semver.valid(parts[parts.length-1])){
// explicit versioned url. for now deliver default json.
parts.pop();
targetVersion = parts.pop();
data.module = parts.join('/');
}
}
Expand All @@ -68,6 +70,10 @@ module.exports = function(config,cb){
if(err) {
doPublic();
} else {

if(targetVersion) {
json = json.versions[targetVersion];
}
json = JSON.stringify(json).replace(/\{REPO ADDRESS\}/g,'http://'+address.address+':'+address.port+'/'+data.bucket);
res.end(json);
}
Expand Down

0 comments on commit 154670a

Please sign in to comment.