docker-parse-image
Advanced tools
Comparing version 1.0.0 to 2.0.0
@@ -15,11 +15,11 @@ module.exports = function(image) { | ||
registry: registry || null, | ||
namespace: namespace || 'library', | ||
namespace: namespace || null, | ||
repository: match[3], | ||
tag: match[4] || 'latest' | ||
tag: match[4] || null | ||
} | ||
result.name = (registry ? registry+'/' : '') + result.namespace + '/' + result.repository | ||
result.fullname = result.name+':'+result.tag | ||
result.name = (registry ? registry+'/' : '') + (namespace ? namespace+'/' : '') + result.repository | ||
result.fullname = result.name+(result.tag ? ':'+result.tag : '') | ||
return result | ||
} |
{ | ||
"name": "docker-parse-image", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Parse docker image urls", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,15 +17,15 @@ # docker-parse-image | ||
console.log(parse('mafintosh/test')) | ||
// --> {namespace:'mafintosh', repository:'test', tag:'latest'} | ||
// --> {namespace:'mafintosh', repository:'test', tag:null} | ||
console.log(parse('ubuntu')) | ||
// --> {namespace:'library', repository:'ubuntu', tag:'latest'} | ||
// --> {namespace:null, repository:'ubuntu', tag:null} | ||
console.log(parse('mafintosh/test:14.04')) | ||
// --> {namespace:'library', repository:'ubuntu', tag:'14.04'} | ||
// --> {namespace:'mafintosh', repository:'test', tag:'14.04'} | ||
console.log(parse('ubuntu:14.04')) | ||
// --> {namespace:'library', repository:'ubuntu', tag:'14.04'} | ||
// --> {namespace:null, repository:'ubuntu', tag:'14.04'} | ||
console.log(parse('registry.com/ubuntu:14.04')) | ||
// --> {registry:'registry.com', namespace:'library', tag:'14.04'} | ||
// --> {registry:'registry.com', namespace:null, tag:'14.04'} | ||
``` | ||
@@ -32,0 +32,0 @@ |
80
test.js
@@ -9,5 +9,5 @@ var parse = require('./') | ||
repository:'test', | ||
tag:'latest', | ||
name: 'mafintosh/test', | ||
fullname: 'mafintosh/test:latest' | ||
tag:null, | ||
name:'mafintosh/test', | ||
fullname:'mafintosh/test' | ||
}) | ||
@@ -17,7 +17,7 @@ | ||
registry:null, | ||
namespace:'library', | ||
namespace:null, | ||
repository:'ubuntu', | ||
tag:'latest', | ||
name: 'library/ubuntu', | ||
fullname: 'library/ubuntu:latest' | ||
tag:null, | ||
name:'ubuntu', | ||
fullname:'ubuntu' | ||
}) | ||
@@ -30,4 +30,4 @@ | ||
tag:'14.04', | ||
name: 'mafintosh/test', | ||
fullname: 'mafintosh/test:14.04' | ||
name:'mafintosh/test', | ||
fullname:'mafintosh/test:14.04' | ||
}) | ||
@@ -37,7 +37,7 @@ | ||
registry:null, | ||
namespace:'library', | ||
namespace:null, | ||
repository:'ubuntu', | ||
tag:'14.04', | ||
name: 'library/ubuntu', | ||
fullname: 'library/ubuntu:14.04' | ||
name:'ubuntu', | ||
fullname:'ubuntu:14.04' | ||
}) | ||
@@ -47,16 +47,16 @@ | ||
registry:'registry.com', | ||
namespace:'library', | ||
namespace:null, | ||
repository:'ubuntu', | ||
tag:'14.04', | ||
name: 'registry.com/library/ubuntu', | ||
fullname: 'registry.com/library/ubuntu:14.04' | ||
name:'registry.com/ubuntu', | ||
fullname:'registry.com/ubuntu:14.04' | ||
}) | ||
t.same(parse('registry.com/library/ubuntu:14.04'), { | ||
t.same(parse('registry.com/ubuntu:14.04'), { | ||
registry:'registry.com', | ||
namespace:'library', | ||
namespace:null, | ||
repository:'ubuntu', | ||
tag:'14.04', | ||
name: 'registry.com/library/ubuntu', | ||
fullname: 'registry.com/library/ubuntu:14.04' | ||
name:'registry.com/ubuntu', | ||
fullname:'registry.com/ubuntu:14.04' | ||
}) | ||
@@ -68,20 +68,2 @@ | ||
tape('basic with @', function(t) { | ||
t.same(parse('mafintosh/test'), { | ||
registry:null, | ||
namespace:'mafintosh', | ||
repository:'test', | ||
tag:'latest', | ||
name: 'mafintosh/test', | ||
fullname: 'mafintosh/test:latest' | ||
}) | ||
t.same(parse('ubuntu'), { | ||
registry:null, | ||
namespace:'library', | ||
repository:'ubuntu', | ||
tag:'latest', | ||
name: 'library/ubuntu', | ||
fullname: 'library/ubuntu:latest' | ||
}) | ||
t.same(parse('mafintosh/test@14.04'), { | ||
@@ -92,4 +74,4 @@ registry:null, | ||
tag:'14.04', | ||
name: 'mafintosh/test', | ||
fullname: 'mafintosh/test:14.04' | ||
name:'mafintosh/test', | ||
fullname:'mafintosh/test:14.04' | ||
}) | ||
@@ -99,7 +81,7 @@ | ||
registry:null, | ||
namespace:'library', | ||
namespace:null, | ||
repository:'ubuntu', | ||
tag:'14.04', | ||
name: 'library/ubuntu', | ||
fullname: 'library/ubuntu:14.04' | ||
name:'ubuntu', | ||
fullname:'ubuntu:14.04' | ||
}) | ||
@@ -109,16 +91,16 @@ | ||
registry:'registry.com', | ||
namespace:'library', | ||
namespace:null, | ||
repository:'ubuntu', | ||
tag:'14.04', | ||
name: 'registry.com/library/ubuntu', | ||
fullname: 'registry.com/library/ubuntu:14.04' | ||
name:'registry.com/ubuntu', | ||
fullname:'registry.com/ubuntu:14.04' | ||
}) | ||
t.same(parse('registry.com/library/ubuntu@14.04'), { | ||
t.same(parse('registry.com/ubuntu@14.04'), { | ||
registry:'registry.com', | ||
namespace:'library', | ||
namespace:null, | ||
repository:'ubuntu', | ||
tag:'14.04', | ||
name: 'registry.com/library/ubuntu', | ||
fullname: 'registry.com/library/ubuntu:14.04' | ||
name:'registry.com/ubuntu', | ||
fullname:'registry.com/ubuntu:14.04' | ||
}) | ||
@@ -125,0 +107,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5292
106