@botonic/react 0.21.5 → 0.21.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/util/environment.js +29 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botonic/react",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Build Chatbots using React",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"README.md"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@botonic/core": "
|
|
32
|
+
"@botonic/core": "^0.21.6",
|
|
33
33
|
"axios": "^0.24.0",
|
|
34
34
|
"emoji-picker-react": "^3.2.3",
|
|
35
35
|
"framer-motion": "^3.1.1",
|
package/src/util/environment.js
CHANGED
|
@@ -13,7 +13,7 @@ export const staticAsset = path => {
|
|
|
13
13
|
return resolvedStaticAssetPath
|
|
14
14
|
} catch (e) {
|
|
15
15
|
console.error(`Could not resolve path: '${path}'`)
|
|
16
|
-
return path
|
|
16
|
+
return normalize(path)
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -27,3 +27,31 @@ export const isURL = urlPath => {
|
|
|
27
27
|
const pattern = new RegExp(/^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/)
|
|
28
28
|
return !!pattern.test(urlPath)
|
|
29
29
|
}
|
|
30
|
+
|
|
31
|
+
export function normalize(path) {
|
|
32
|
+
const isAbsolute = path.charAt(0) === '/'
|
|
33
|
+
const trailingSlash = path && path[path.length - 1] === '/'
|
|
34
|
+
// Normalize the path
|
|
35
|
+
path = normalizeArray(path.split('/'), !isAbsolute).join('/')
|
|
36
|
+
if (!path && !isAbsolute) path = '.'
|
|
37
|
+
if (path && trailingSlash) path += '/'
|
|
38
|
+
return (isAbsolute ? '/' : '') + path
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function normalizeArray(parts, allowAboveRoot) {
|
|
42
|
+
const res = []
|
|
43
|
+
for (let i = 0; i < parts.length; i++) {
|
|
44
|
+
const p = parts[i]
|
|
45
|
+
if (!p || p === '.') continue
|
|
46
|
+
if (p === '..') {
|
|
47
|
+
if (res.length && res[res.length - 1] !== '..') {
|
|
48
|
+
res.pop()
|
|
49
|
+
} else if (allowAboveRoot) {
|
|
50
|
+
res.push('..')
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
res.push(p)
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return res
|
|
57
|
+
}
|