@takeshape/routing 9.80.3 → 9.81.0
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/dist/index.js +0 -4
- package/dist/paths.js +2 -15
- package/dist/urls.js +0 -11
- package/es/paths.js +2 -7
- package/es/urls.js +0 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _urls = require("./urls");
|
|
8
|
-
|
|
9
7
|
Object.keys(_urls).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _urls[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_urls).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _paths = require("./paths");
|
|
21
|
-
|
|
22
18
|
Object.keys(_paths).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _paths[key]) return;
|
package/dist/paths.js
CHANGED
|
@@ -5,21 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.formatPath = formatPath;
|
|
7
7
|
exports.route = void 0;
|
|
8
|
-
|
|
9
8
|
var _slugg = _interopRequireDefault(require("slugg"));
|
|
10
|
-
|
|
11
9
|
var _get = _interopRequireDefault(require("lodash/get"));
|
|
12
|
-
|
|
13
10
|
var _toPath = _interopRequireDefault(require("lodash/toPath"));
|
|
14
|
-
|
|
15
11
|
var _curry = _interopRequireDefault(require("lodash/curry"));
|
|
16
|
-
|
|
17
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
const nameGroup = '([a-zA-Z][a-zA-Z0-9.]*)';
|
|
14
|
+
// eslint-disable-next-line security-node/non-literal-reg-expr
|
|
21
15
|
const variableRegex = new RegExp(':' + nameGroup + '|{' + nameGroup + '}', 'g');
|
|
22
|
-
|
|
23
16
|
function formatPath(pathStr, data) {
|
|
24
17
|
const result = {
|
|
25
18
|
warnings: [],
|
|
@@ -28,27 +21,21 @@ function formatPath(pathStr, data) {
|
|
|
28
21
|
result.path = pathStr.replace(variableRegex, (_, colon, curly) => {
|
|
29
22
|
const type = typeof data;
|
|
30
23
|
const propPath = colon || curly;
|
|
31
|
-
|
|
32
24
|
if (type === 'object') {
|
|
33
25
|
const value = String((0, _get.default)(data, propPath) || '');
|
|
34
|
-
|
|
35
26
|
if (value === '') {
|
|
36
27
|
result.warnings.push(propPath);
|
|
37
28
|
}
|
|
38
|
-
|
|
39
29
|
return (0, _slugg.default)(value);
|
|
40
30
|
}
|
|
41
|
-
|
|
42
31
|
if (propPath === 'num' || propPath === 'value') {
|
|
43
32
|
return (0, _slugg.default)(String(data));
|
|
44
33
|
}
|
|
45
|
-
|
|
46
34
|
result.warnings.push(propPath);
|
|
47
35
|
return '';
|
|
48
36
|
});
|
|
49
37
|
return result;
|
|
50
38
|
}
|
|
51
|
-
|
|
52
39
|
const route = (0, _curry.default)((config, routeName, data) => {
|
|
53
40
|
const path = (0, _get.default)(config, ['routes'].concat((0, _toPath.default)(routeName), 'path'));
|
|
54
41
|
return formatPath(path, data).path;
|
package/dist/urls.js
CHANGED
|
@@ -8,44 +8,33 @@ exports.getAssetUrl = getAssetUrl;
|
|
|
8
8
|
exports.getImageUrl = getImageUrl;
|
|
9
9
|
exports.getPath = getPath;
|
|
10
10
|
exports.imageBaseUrl = void 0;
|
|
11
|
-
|
|
12
11
|
var _queryString = _interopRequireDefault(require("query-string"));
|
|
13
|
-
|
|
14
12
|
var _pickBy = _interopRequireDefault(require("lodash/pickBy"));
|
|
15
|
-
|
|
16
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
14
|
const imageBaseUrl = 'https://images.takeshape.io';
|
|
19
15
|
exports.imageBaseUrl = imageBaseUrl;
|
|
20
16
|
const assetBaseUrl = 'https://assets.takeshape.io';
|
|
21
17
|
exports.assetBaseUrl = assetBaseUrl;
|
|
22
|
-
|
|
23
18
|
function getPath(key) {
|
|
24
19
|
return typeof key === 'object' ? 'path' in key ? key.path : key.s3Key : key;
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
function formatQuery(query) {
|
|
28
22
|
if (query) {
|
|
29
23
|
const filtered = (0, _pickBy.default)(query, value => value !== '');
|
|
30
|
-
|
|
31
24
|
if (Object.keys(filtered).length) {
|
|
32
25
|
return '?' + _queryString.default.stringify(filtered);
|
|
33
26
|
}
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
return '';
|
|
37
29
|
}
|
|
38
|
-
|
|
39
30
|
function escapePath(path) {
|
|
40
31
|
return path.split('/').map(encodeURIComponent).join('/');
|
|
41
32
|
}
|
|
42
|
-
|
|
43
33
|
function getAssetUrl(s3Key, options = {}) {
|
|
44
34
|
const path = getPath(s3Key);
|
|
45
35
|
const baseUrl = options.baseUrl ?? assetBaseUrl;
|
|
46
36
|
return path ? `${baseUrl}/${escapePath(path)}` : '';
|
|
47
37
|
}
|
|
48
|
-
|
|
49
38
|
function getImageUrl(key, query, options = {}) {
|
|
50
39
|
const path = getPath(key);
|
|
51
40
|
const baseUrl = options.baseUrl ?? imageBaseUrl;
|
package/es/paths.js
CHANGED
|
@@ -2,8 +2,8 @@ import slug from 'slugg';
|
|
|
2
2
|
import get from 'lodash/get';
|
|
3
3
|
import toPath from 'lodash/toPath';
|
|
4
4
|
import curry from 'lodash/curry';
|
|
5
|
-
const nameGroup = '([a-zA-Z][a-zA-Z0-9.]*)';
|
|
6
|
-
|
|
5
|
+
const nameGroup = '([a-zA-Z][a-zA-Z0-9.]*)';
|
|
6
|
+
// eslint-disable-next-line security-node/non-literal-reg-expr
|
|
7
7
|
const variableRegex = new RegExp(':' + nameGroup + '|{' + nameGroup + '}', 'g');
|
|
8
8
|
export function formatPath(pathStr, data) {
|
|
9
9
|
const result = {
|
|
@@ -13,21 +13,16 @@ export function formatPath(pathStr, data) {
|
|
|
13
13
|
result.path = pathStr.replace(variableRegex, (_, colon, curly) => {
|
|
14
14
|
const type = typeof data;
|
|
15
15
|
const propPath = colon || curly;
|
|
16
|
-
|
|
17
16
|
if (type === 'object') {
|
|
18
17
|
const value = String(get(data, propPath) || '');
|
|
19
|
-
|
|
20
18
|
if (value === '') {
|
|
21
19
|
result.warnings.push(propPath);
|
|
22
20
|
}
|
|
23
|
-
|
|
24
21
|
return slug(value);
|
|
25
22
|
}
|
|
26
|
-
|
|
27
23
|
if (propPath === 'num' || propPath === 'value') {
|
|
28
24
|
return slug(String(data));
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
result.warnings.push(propPath);
|
|
32
27
|
return '';
|
|
33
28
|
});
|
package/es/urls.js
CHANGED
|
@@ -5,23 +5,18 @@ export const assetBaseUrl = 'https://assets.takeshape.io';
|
|
|
5
5
|
export function getPath(key) {
|
|
6
6
|
return typeof key === 'object' ? 'path' in key ? key.path : key.s3Key : key;
|
|
7
7
|
}
|
|
8
|
-
|
|
9
8
|
function formatQuery(query) {
|
|
10
9
|
if (query) {
|
|
11
10
|
const filtered = pickBy(query, value => value !== '');
|
|
12
|
-
|
|
13
11
|
if (Object.keys(filtered).length) {
|
|
14
12
|
return '?' + queryString.stringify(filtered);
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
return '';
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
function escapePath(path) {
|
|
22
18
|
return path.split('/').map(encodeURIComponent).join('/');
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
export function getAssetUrl(s3Key, options = {}) {
|
|
26
21
|
const path = getPath(s3Key);
|
|
27
22
|
const baseUrl = options.baseUrl ?? assetBaseUrl;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/routing",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.81.0",
|
|
4
4
|
"homepage": "https://www.takeshape.io",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/lodash": "^4.14.165",
|
|
26
|
-
"@takeshape/typescript-jest-junit-reporter": "9.
|
|
26
|
+
"@takeshape/typescript-jest-junit-reporter": "9.81.0"
|
|
27
27
|
},
|
|
28
28
|
"engines": {
|
|
29
29
|
"node": ">=16"
|