@bedrockio/templates 0.3.0 → 0.3.2
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/CHANGELOG.md +8 -0
- package/dist/cjs/helpers.js +1 -1
- package/dist/cjs/utils.js +4 -1
- package/dist/esm/helpers.js +1 -1
- package/dist/esm/utils.js +4 -1
- package/package.json +1 -1
- package/types/utils.d.ts.map +1 -1
package/CHANGELOG.md
CHANGED
package/dist/cjs/helpers.js
CHANGED
|
@@ -128,7 +128,7 @@ function resolveHelper(arg, options) {
|
|
|
128
128
|
};
|
|
129
129
|
}
|
|
130
130
|
// Arguments
|
|
131
|
-
const ARGUMENT_NAMES_REG = /\w+\((.+)\) {/;
|
|
131
|
+
const ARGUMENT_NAMES_REG = /\w+\s?\((.+)\) {/;
|
|
132
132
|
function resolveArgumentNames(arg) {
|
|
133
133
|
if (typeof arg === 'function') {
|
|
134
134
|
const handler = arg;
|
package/dist/cjs/utils.js
CHANGED
|
@@ -13,7 +13,7 @@ const front_matter_1 = __importDefault(require("front-matter"));
|
|
|
13
13
|
function resolveTemplateSource(arg, options) {
|
|
14
14
|
const { dir } = options;
|
|
15
15
|
let source;
|
|
16
|
-
if (dir) {
|
|
16
|
+
if (dir && isValidFilename(arg)) {
|
|
17
17
|
const filepath = path_1.default.resolve(dir, arg);
|
|
18
18
|
source = readSource(filepath) || arg;
|
|
19
19
|
}
|
|
@@ -47,6 +47,9 @@ function readSource(filepath) {
|
|
|
47
47
|
return tryReadFile(filepath + '.md') || tryReadFile(filepath + '.txt');
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
+
function isValidFilename(str) {
|
|
51
|
+
return str.length <= 255 && !str.includes('\n');
|
|
52
|
+
}
|
|
50
53
|
// Sections
|
|
51
54
|
const SECTIONS_REG = /^=== (\w+) ===\n\n/gm;
|
|
52
55
|
function getSections(str) {
|
package/dist/esm/helpers.js
CHANGED
|
@@ -121,7 +121,7 @@ function resolveHelper(arg, options) {
|
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
// Arguments
|
|
124
|
-
const ARGUMENT_NAMES_REG = /\w+\((.+)\) {/;
|
|
124
|
+
const ARGUMENT_NAMES_REG = /\w+\s?\((.+)\) {/;
|
|
125
125
|
function resolveArgumentNames(arg) {
|
|
126
126
|
if (typeof arg === 'function') {
|
|
127
127
|
const handler = arg;
|
package/dist/esm/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ import frontmatter from 'front-matter';
|
|
|
4
4
|
export function resolveTemplateSource(arg, options) {
|
|
5
5
|
const { dir } = options;
|
|
6
6
|
let source;
|
|
7
|
-
if (dir) {
|
|
7
|
+
if (dir && isValidFilename(arg)) {
|
|
8
8
|
const filepath = path.resolve(dir, arg);
|
|
9
9
|
source = readSource(filepath) || arg;
|
|
10
10
|
}
|
|
@@ -38,6 +38,9 @@ function readSource(filepath) {
|
|
|
38
38
|
return tryReadFile(filepath + '.md') || tryReadFile(filepath + '.txt');
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
function isValidFilename(str) {
|
|
42
|
+
return str.length <= 255 && !str.includes('\n');
|
|
43
|
+
}
|
|
41
44
|
// Sections
|
|
42
45
|
const SECTIONS_REG = /^=== (\w+) ===\n\n/gm;
|
|
43
46
|
export function getSections(str) {
|
package/package.json
CHANGED
package/types/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAKA,mEAYC;AAED;;;EAOC;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAKA,mEAYC;AAED;;;EAOC;AA4BD;;;;;IAsBC;AAMD,6CAMC"}
|