unhead 1.1.7 → 1.1.8

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.cjs CHANGED
@@ -279,17 +279,17 @@ const DedupesTagsPlugin = (options) => {
279
279
  };
280
280
 
281
281
  function processTemplateParams(s, config) {
282
- const replacer = (preserveToken) => (_, token) => {
283
- if (token === "pageTitle" || token === "s")
284
- return config.pageTitle;
282
+ const sub = (_, token) => {
285
283
  let val;
286
- if (token.includes("."))
287
- val = token.split(".").reduce((acc, key) => acc[key] || {}, config);
284
+ if (token === "pageTitle" || token === "s")
285
+ val = config.pageTitle;
286
+ else if (token.includes("."))
287
+ val = token.split(".").reduce((acc, key) => acc[key] || "", config);
288
288
  else
289
289
  val = config[token];
290
- return val || (preserveToken ? token : "");
290
+ return val || "";
291
291
  };
292
- let template = s.replace(/%(\w+\.?\w*)%/g, replacer()).replace(/%(\w+\.?\w*)/g, replacer(true)).trim();
292
+ let template = s.replace(/%(\w+\.+\w+)/g, sub).replace(/%(\w+)/g, sub).trim();
293
293
  if (config.separator) {
294
294
  if (template.endsWith(config.separator))
295
295
  template = template.slice(0, -config.separator.length).trim();
package/dist/index.mjs CHANGED
@@ -278,17 +278,17 @@ const DedupesTagsPlugin = (options) => {
278
278
  };
279
279
 
280
280
  function processTemplateParams(s, config) {
281
- const replacer = (preserveToken) => (_, token) => {
282
- if (token === "pageTitle" || token === "s")
283
- return config.pageTitle;
281
+ const sub = (_, token) => {
284
282
  let val;
285
- if (token.includes("."))
286
- val = token.split(".").reduce((acc, key) => acc[key] || {}, config);
283
+ if (token === "pageTitle" || token === "s")
284
+ val = config.pageTitle;
285
+ else if (token.includes("."))
286
+ val = token.split(".").reduce((acc, key) => acc[key] || "", config);
287
287
  else
288
288
  val = config[token];
289
- return val || (preserveToken ? token : "");
289
+ return val || "";
290
290
  };
291
- let template = s.replace(/%(\w+\.?\w*)%/g, replacer()).replace(/%(\w+\.?\w*)/g, replacer(true)).trim();
291
+ let template = s.replace(/%(\w+\.+\w+)/g, sub).replace(/%(\w+)/g, sub).trim();
292
292
  if (config.separator) {
293
293
  if (template.endsWith(config.separator))
294
294
  template = template.slice(0, -config.separator.length).trim();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unhead",
3
3
  "type": "module",
4
- "version": "1.1.7",
4
+ "version": "1.1.8",
5
5
  "packageManager": "pnpm@7.27.1",
6
6
  "author": "Harlan Wilton <harlan@harlanzw.com>",
7
7
  "license": "MIT",
@@ -32,9 +32,9 @@
32
32
  "dependencies": {
33
33
  "hookable": "^5.4.2",
34
34
  "packrup": "^0.1.0",
35
- "@unhead/dom": "1.1.7",
36
- "@unhead/schema": "1.1.7",
37
- "@unhead/shared": "1.1.7"
35
+ "@unhead/dom": "1.1.8",
36
+ "@unhead/schema": "1.1.8",
37
+ "@unhead/shared": "1.1.8"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "unbuild .",