content-entry-transform 1.2.0 → 1.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "content-entry-transform",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -1,3 +1,5 @@
1
+ import { nameExtensionMatcher } from "./matcher.mjs";
2
+
1
3
  export function createPropertiesInterceptor(properties) {
2
4
  return async function* transformer(expression, remainder, source, cb) {
3
5
  const value = properties[expression];
@@ -6,12 +8,19 @@ export function createPropertiesInterceptor(properties) {
6
8
  }
7
9
 
8
10
  export function createExpressionTransformer(
11
+ match = nameExtensionMatcher([
12
+ ".conf",
13
+ ".json",
14
+ ".html",
15
+ ".txt",
16
+ ".service",
17
+ ".socket"
18
+ ]),
9
19
  properties,
10
- match = entry =>
11
- entry.name.match(/\.(conf|json|html|txt|service|socket)$/) ? true : false
20
+ name = "expression"
12
21
  ) {
13
22
  return {
14
- name: "expression",
23
+ name,
15
24
  match,
16
25
  transform: async entry => {
17
26
  //console.log("TRANSFORM",entry.name);
package/src/matcher.mjs CHANGED
@@ -1,5 +1,6 @@
1
+
1
2
  export function nameExtensionMatcher(extensions)
2
3
  {
3
- const r = RegExp(`(${extensions.join('|')})$`);
4
- return (entry) => entry.name.match(r) ? true : false;
4
+ const r = new RegExp(`(${extensions.map(x => x.replace(/\./,"\\.")).join('|')})$`);
5
+ return (entry) => r.test(entry.name);
5
6
  }