strapi-utils
Advanced tools
Comparing version 3.6.6 to 3.6.7
'use strict'; | ||
const _ = require('lodash'); | ||
const { getCommonBeginning } = require('./string-formatting'); | ||
const { getCommonPath } = require('./string-formatting'); | ||
@@ -49,3 +49,3 @@ const getConfigUrls = (serverConfig, forAdminBuild = false) => { | ||
) { | ||
adminPath = adminUrl.replace(getCommonBeginning(serverUrl, adminUrl), ''); | ||
adminPath = adminUrl.replace(getCommonPath(serverUrl, adminUrl), ''); | ||
adminPath = `/${_.trim(adminPath, '/')}`; | ||
@@ -52,0 +52,0 @@ } else if (adminUrl.startsWith('http')) { |
'use strict'; | ||
const _ = require('lodash'); | ||
const slugify = require('@sindresorhus/slugify'); | ||
@@ -9,14 +9,12 @@ | ||
const getCommonBeginning = (str1 = '', str2 = '') => { | ||
let common = ''; | ||
let index = 0; | ||
while (index < str1.length && index < str2.length) { | ||
if (str1[index] === str2[index]) { | ||
common += str1[index]; | ||
index += 1; | ||
} else { | ||
break; | ||
} | ||
} | ||
return common; | ||
const getCommonBeginning = (...strings) => _.takeWhile( | ||
strings[0], | ||
(char, index) => strings.every(string => string[index] === char) | ||
).join(''); | ||
const getCommonPath = (...paths) => { | ||
const [segments, ...otherSegments] = paths.map(it => _.split(it, '/')); | ||
return _.join( | ||
_.takeWhile(segments, (str, index) => otherSegments.every(it => it[index] === str)) | ||
, '/'); | ||
}; | ||
@@ -43,2 +41,3 @@ | ||
getCommonBeginning, | ||
getCommonPath, | ||
escapeQuery, | ||
@@ -45,0 +44,0 @@ stringIncludes, |
{ | ||
"name": "strapi-utils", | ||
"version": "3.6.6", | ||
"version": "3.6.7", | ||
"description": "Shared utilities for the Strapi packages", | ||
@@ -48,3 +48,3 @@ "homepage": "https://strapi.io", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"gitHead": "e63fb9d5093de3c099a487e7d87f48ffb8029a24" | ||
"gitHead": "5202c4ed5c96d5e39823e8e6e936bb75c2c59a33" | ||
} |
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
68218
2020