@nuxt/utils
Advanced tools
+67
-18
| /*! | ||
| * @nuxt/utils v2.6.3 (c) 2016-2019 | ||
| * @nuxt/utils v2.7.0 (c) 2016-2019 | ||
@@ -21,2 +21,4 @@ * - All the amazing contributors | ||
| const serialize = _interopDefault(require('serialize-javascript')); | ||
| const UAParser = _interopDefault(require('ua-parser-js')); | ||
| const semver = _interopDefault(require('semver')); | ||
@@ -47,5 +49,3 @@ const getContext = function getContext(req, res) { | ||
| const isPureObject = function isPureObject(o) { | ||
| return !Array.isArray(o) && typeof o === 'object' | ||
| }; | ||
| const isPureObject = obj => !Array.isArray(obj) && typeof obj === 'object'; | ||
@@ -540,11 +540,11 @@ const isUrl = function isUrl(url) { | ||
| // Resolve path | ||
| const _path = r(...args); | ||
| const resolvedPath = r(...args); | ||
| // Check if path is an alias | ||
| if (startsWithSrcAlias(_path)) { | ||
| return _path | ||
| if (startsWithSrcAlias(resolvedPath)) { | ||
| return resolvedPath | ||
| } | ||
| // Make correct relative path | ||
| let rp = path.relative(dir, _path); | ||
| let rp = path.relative(dir, resolvedPath); | ||
| if (rp[0] !== '.') { | ||
@@ -1510,3 +1510,3 @@ rp = '.' + path.sep + rp; | ||
| const flatRoutes = function flatRoutes(router, _path = '', routes = []) { | ||
| const flatRoutes = function flatRoutes(router, fileName = '', routes = []) { | ||
| router.forEach((r) => { | ||
@@ -1517,12 +1517,12 @@ if ([':', '*'].some(c => r.path.includes(c))) { | ||
| if (r.children) { | ||
| if (_path === '' && r.path === '/') { | ||
| if (fileName === '' && r.path === '/') { | ||
| routes.push('/'); | ||
| } | ||
| return flatRoutes(r.children, _path + r.path + '/', routes) | ||
| return flatRoutes(r.children, fileName + r.path + '/', routes) | ||
| } | ||
| _path = _path.replace(/^\/+$/, '/'); | ||
| fileName = fileName.replace(/^\/+$/, '/'); | ||
| routes.push( | ||
| (r.path === '' && _path[_path.length - 1] === '/' | ||
| ? _path.slice(0, -1) | ||
| : _path) + r.path | ||
| (r.path === '' && fileName[fileName.length - 1] === '/' | ||
| ? fileName.slice(0, -1) | ||
| : fileName) + r.path | ||
| ); | ||
@@ -1757,7 +1757,7 @@ }); | ||
| const asString = obj[key].toString(); | ||
| const match = asString.match(/^([^{(]+)=>\s*(.*)/s); | ||
| const match = asString.match(/^([^{(]+)=>\s*([\0-\uFFFF]*)/); | ||
| if (match) { | ||
| const fullFunctionBody = match[2].match(/^{?(\s*return\s+)?(.*?)}?$/s); | ||
| const fullFunctionBody = match[2].match(/^{?(\s*return\s+)?([\0-\uFFFF]*?)}?$/); | ||
| let functionBody = fullFunctionBody[2].trim(); | ||
| if (fullFunctionBody[1] || !match[2].trim().match(/^\s*{/s)) { | ||
| if (fullFunctionBody[1] || !match[2].trim().match(/^\s*{/)) { | ||
| functionBody = `return ${functionBody}`; | ||
@@ -1929,2 +1929,49 @@ } | ||
| const ModernBrowsers = { | ||
| Edge: '16', | ||
| Firefox: '60', | ||
| Chrome: '61', | ||
| 'Chrome Headless': '61', | ||
| Chromium: '61', | ||
| Iron: '61', | ||
| Safari: '10.1', | ||
| Opera: '48', | ||
| Yandex: '18', | ||
| Vivaldi: '1.14', | ||
| 'Mobile Safari': '10.3' | ||
| }; | ||
| const modernBrowsers = Object.keys(ModernBrowsers) | ||
| .reduce((allBrowsers, browser) => { | ||
| allBrowsers[browser] = semver.coerce(ModernBrowsers[browser]); | ||
| return allBrowsers | ||
| }, {}); | ||
| const isModernBrowser = (ua) => { | ||
| if (!ua) { | ||
| return false | ||
| } | ||
| const { browser } = UAParser(ua); | ||
| const browserVersion = semver.coerce(browser.version); | ||
| if (!browserVersion) { | ||
| return false | ||
| } | ||
| return Boolean(modernBrowsers[browser.name] && semver.gte(browserVersion, modernBrowsers[browser.name])) | ||
| }; | ||
| const isModernRequest = (req, modernMode = false) => { | ||
| if (modernMode === false) { | ||
| return false | ||
| } | ||
| const { socket = {}, headers } = req; | ||
| if (socket._modern === undefined) { | ||
| const ua = headers && headers['user-agent']; | ||
| socket._modern = isModernBrowser(ua); | ||
| } | ||
| return socket._modern | ||
| }; | ||
| exports.ModernBrowsers = ModernBrowsers; | ||
| exports.Timer = Timer; | ||
@@ -1946,2 +1993,4 @@ exports.chainFn = chainFn; | ||
| exports.isIndexFileAndFolder = isIndexFileAndFolder; | ||
| exports.isModernBrowser = isModernBrowser; | ||
| exports.isModernRequest = isModernRequest; | ||
| exports.isNonEmptyString = isNonEmptyString; | ||
@@ -1948,0 +1997,0 @@ exports.isPureObject = isPureObject; |
+7
-5
| { | ||
| "name": "@nuxt/utils", | ||
| "version": "2.6.3", | ||
| "version": "2.7.0", | ||
| "repository": "nuxt/nuxt.js", | ||
@@ -11,8 +11,10 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "consola": "^2.6.0", | ||
| "fs-extra": "^7.0.1", | ||
| "consola": "^2.6.1", | ||
| "fs-extra": "^8.0.1", | ||
| "hash-sum": "^1.0.2", | ||
| "proper-lockfile": "^4.1.1", | ||
| "serialize-javascript": "^1.6.1", | ||
| "signal-exit": "^3.0.2" | ||
| "semver": "^6.0.0", | ||
| "serialize-javascript": "^1.7.0", | ||
| "signal-exit": "^3.0.2", | ||
| "ua-parser-js": "^0.7.19" | ||
| }, | ||
@@ -19,0 +21,0 @@ "publishConfig": { |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
51645
2.75%1743
2.53%8
33.33%+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
Updated
Updated
Updated