Skip to content

Commit

Permalink
only set if not already set
Browse files Browse the repository at this point in the history
  • Loading branch information
cadorn committed Mar 4, 2013
1 parent 117f082 commit 3cbc306
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions plugin.js
Expand Up @@ -8,23 +8,25 @@ exports.for = function(API, plugin) {
locator.url = locator.descriptor.pointer;
}

locator.getLocation = function(type) {
var locations = {
"pointer": locator.url
};
if (/\.zip$/.test(locator.url)) {
locations.archive = locations.zip = locator.url;
} else
if (/(\.tgz|\.tar\.gz)$/.test(locator.url)) {
locations.archive = locations.gzip = locator.url;
} else
if (/(\.tar\.bz2)$/.test(locator.url)) {
locations.archive = locations.bzip = locator.url;
} else
if (/(\.7z)$/.test(locator.url)) {
locations.archive = locations["7zip"] = locator.url;
if (!locator.hasOwnProperty("getLocation")) {
locator.getLocation = function(type) {
var locations = {
"pointer": locator.url
};
if (/\.zip$/.test(locator.url)) {
locations.archive = locations.zip = locator.url;
} else
if (/(\.tgz|\.tar\.gz)$/.test(locator.url)) {
locations.archive = locations.gzip = locator.url;
} else
if (/(\.tar\.bz2)$/.test(locator.url)) {
locations.archive = locations.bzip = locator.url;
} else
if (/(\.7z)$/.test(locator.url)) {
locations.archive = locations["7zip"] = locator.url;
}
return (type)?locations[type]:locations;
}
return (type)?locations[type]:locations;
}

return callback(null, locator);
Expand Down

0 comments on commit 3cbc306

Please sign in to comment.