@bedrockio/templates 0.3.0 → 0.3.1

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 CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.1
2
+
3
+ - Fixed issue with long filenames.
4
+
1
5
  ## 0.3.0
2
6
 
3
7
  - Allow getting template source.
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/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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrockio/templates",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Bedrock utility for custom templates.",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAKA,mEAYC;AAED;;;EAOC;AAwBD;;;;;IAsBC;AAMD,6CAMC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names":[],"mappings":"AAKA,mEAYC;AAED;;;EAOC;AA4BD;;;;;IAsBC;AAMD,6CAMC"}