Socket
Socket
Sign inDemoInstall

snyk-module

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snyk-module - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

36

lib/index.js

@@ -8,3 +8,9 @@ module.exports = moduleToObject;

function moduleToObject(str) {
/**
* Converts a string module name to an object
* @param {String} str Required module name (can also include @version)
* @param {String} version Optional version
* @return {Object} Containing .name & .version properties
*/
function moduleToObject(str, version) {
if (!str) {

@@ -14,8 +20,12 @@ throw new Error('requires string to parse into module');

debug('module to object from: %s', str);
if (version && str.lastIndexOf('@') < 1) {
debug('appending version onto string');
str += '@' + version;
}
var url = looksLikeUrl(str);
if (url) {
var gitObject = looksLikeUrl(str);
if (gitObject) {
// then the string looks like a url, let's try to parse it
return supported(fromUrl(url));
return supported(str, fromGitObject(gitObject));
}

@@ -40,5 +50,3 @@

debug('parsed from string');
return supported(module);
return supported(str, module);
}

@@ -57,6 +65,6 @@

function fromUrl(obj) {
function fromGitObject(obj) {
var error = false;
debug('parsed from hosted-git-info');
// debug('parsed from hosted-git-info');

@@ -80,3 +88,3 @@ /* istanbul ignore if */

return supported(module);
return module;
}

@@ -88,3 +96,3 @@

function supported(module) {
function supported(str, module) {
var error;

@@ -97,2 +105,3 @@

', errors: ' + (valid.warnings || valid.errors || []).join('\n'));
debug('not supported %s@%s (ext)', module.name, module.version);
throw error;

@@ -119,2 +128,5 @@ }

debug('%s => { name: "%s", version: "%s" }',
str, module.name, module.version);
return module;

@@ -121,0 +133,0 @@ }

@@ -31,3 +31,3 @@ {

},
"version": "1.3.0"
"version": "1.4.0"
}

@@ -10,5 +10,9 @@ # snyk/module

Note that at this time the following are not supported in Snyk:
## Testing manually
- Private npm modules
- External modules, i.e. those loaded over http or git
You can use this module from the terminal whilst inside the root of the repo directory:
```bash
$ node . foo@3
{ name: "foo", version: 3 }
```

@@ -15,2 +15,5 @@ var test = require('tap').test;

t.deepEqual(mod('jsbin', 1), { name: 'jsbin', version: '1' }, 'version arg works');
t.deepEqual(mod('@remy/jsbin', 1), { name: '@remy/jsbin', version: '1' }, 'scoped with version arg works');
[

@@ -17,0 +20,0 @@ 'a@1',

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc