Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

globalyzer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

globalyzer - npm Package Compare versions

Comparing version 0.1.0 to 0.1.4

8

package.json
{
"name": "globalyzer",
"version": "0.1.0",
"description": "Detects and extract the glob part of a string",
"version": "0.1.4",
"description": "Detect and extract the static part of a glob string",
"main": "src/index.js",

@@ -25,5 +25,5 @@ "repository": {

"devDependencies": {
"tap-spec": "^4.1.1",
"tape": "^4.9.0"
"tap-spec": "^4.1.2",
"tape": "^4.9.2"
}
}

@@ -1,4 +0,4 @@

# globalyzer
# globalyzer [![Build Status](https://travis-ci.org/terkelg/globalyzer.svg?branch=master)](https://travis-ci.org/terkelg/globalyzer)[![Build status](https://ci.appveyor.com/api/projects/status/0xqnmxt99rsnnjqh?svg=true)](https://ci.appveyor.com/project/terkelg/globalyzer)
> Detect and extract the glob part of a string
> Detect and extract the static part of a glob string

@@ -33,3 +33,3 @@ Utility to detect if a string contains a glob and then split it in a glob and none-glob part.

Returns an object with the (non-glob) base path and the actual pattern.
Returns an object with the (non-glob) base path and the actual pattern and a is-glob flag.

@@ -36,0 +36,0 @@ #### options.strict

@@ -1,7 +0,2 @@

'use strict';
const os = require('os');
const path = require('path');
const isWin = os.platform() === 'win32';
const CHARS = { '{': '}', '(': ')', '[': ']'};

@@ -48,16 +43,15 @@ const STRICT = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\)|(\\).|([@?!+*]\(.*\)))/;

function parent(str, { strict = false } = {}) {
if (isWin && str.includes('/'))
str = str.split('\\').join('/');
str = path.normalize(str).replace(/\/|\\/, '/');
// special case for strings ending in enclosure containing path separator
if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/';
// special case for strings ending in enclosure containing path separator
if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/';
// preserves full path in case of trailing path separator
str += 'a';
// preserves full path in case of trailing path separator
str += 'a';
do {str = path.dirname(str)}
while (isglob(str, {strict}) || /(^|[^\\])([\{\[]|\([^\)]+$)/.test(str));
do {str = path.dirname(str)}
while (isglob(str, {strict}) || /(^|[^\\])([\{\[]|\([^\)]+$)/.test(str));
// remove escape chars and return result
return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1');
// remove escape chars and return result
return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1');
};

@@ -74,22 +68,22 @@

function globalyzer(pattern, opts = {}) {
let base = parent(pattern, opts);
let isGlob = isglob(pattern, opts);
let glob;
let base = parent(pattern, opts);
let isGlob = isglob(pattern, opts);
let glob;
if (base != '.') {
glob = pattern.substr(base.length);
if (glob.startsWith('/')) glob = glob.substr(1);
} else {
glob = pattern;
}
if (base != '.') {
glob = pattern.substr(base.length);
if (glob.startsWith('/')) glob = glob.substr(1);
} else {
glob = pattern;
}
if (!isGlob) {
base = path.dirname(pattern);
glob = base !== '.' ? pattern.substr(base.length) : pattern;
}
if (!isGlob) {
base = path.dirname(pattern);
glob = base !== '.' ? pattern.substr(base.length) : pattern;
}
if (glob.startsWith('./')) glob = glob.substr(2);
if (glob.startsWith('/')) glob = glob.substr(1);
if (glob.startsWith('./')) glob = glob.substr(2);
if (glob.startsWith('/')) glob = glob.substr(1);
return { base, glob, isGlob };
return { base, glob, isGlob };
}

@@ -96,0 +90,0 @@

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