@unhead/shared 1.11.10 → 1.11.12

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
@@ -676,7 +676,7 @@ function tagDedupeKey(tag) {
676
676
  }
677
677
 
678
678
  const sepSub = "%separator";
679
- function sub(p, token) {
679
+ function sub(p, token, isJson = false) {
680
680
  let val;
681
681
  if (token === "s" || token === "pageTitle") {
682
682
  val = p.pageTitle;
@@ -686,10 +686,13 @@ function sub(p, token) {
686
686
  } else {
687
687
  val = p[token];
688
688
  }
689
- return val !== void 0 ? (val || "").replace(/"/g, '\\"') : void 0;
689
+ if (val !== void 0) {
690
+ return isJson ? (val || "").replace(/"/g, '\\"') : val || "";
691
+ }
692
+ return void 0;
690
693
  }
691
694
  const sepSubRe = new RegExp(`${sepSub}(?:\\s*${sepSub})*`, "g");
692
- function processTemplateParams(s, p, sep) {
695
+ function processTemplateParams(s, p, sep, isJson = false) {
693
696
  if (typeof s !== "string" || !s.includes("%"))
694
697
  return s;
695
698
  let decoded = s;
@@ -706,7 +709,7 @@ function processTemplateParams(s, p, sep) {
706
709
  if (token === sepSub || !tokens.includes(token)) {
707
710
  return token;
708
711
  }
709
- const re = sub(p, token.slice(1));
712
+ const re = sub(p, token.slice(1), isJson);
710
713
  return re !== void 0 ? re : token;
711
714
  }).trim();
712
715
  if (hasSepSub) {
package/dist/index.d.cts CHANGED
@@ -62,7 +62,7 @@ declare const SortModifiers: {
62
62
 
63
63
  declare function tagDedupeKey<T extends HeadTag>(tag: T): string | false;
64
64
 
65
- declare function processTemplateParams(s: string, p: TemplateParams, sep: string): string;
65
+ declare function processTemplateParams(s: string, p: TemplateParams, sep: string, isJson?: boolean): string;
66
66
 
67
67
  declare function resolveTitleTemplate(template: string | ((title?: string) => string | null) | null, title?: string): string | null;
68
68
 
package/dist/index.d.mts CHANGED
@@ -62,7 +62,7 @@ declare const SortModifiers: {
62
62
 
63
63
  declare function tagDedupeKey<T extends HeadTag>(tag: T): string | false;
64
64
 
65
- declare function processTemplateParams(s: string, p: TemplateParams, sep: string): string;
65
+ declare function processTemplateParams(s: string, p: TemplateParams, sep: string, isJson?: boolean): string;
66
66
 
67
67
  declare function resolveTitleTemplate(template: string | ((title?: string) => string | null) | null, title?: string): string | null;
68
68
 
package/dist/index.d.ts CHANGED
@@ -62,7 +62,7 @@ declare const SortModifiers: {
62
62
 
63
63
  declare function tagDedupeKey<T extends HeadTag>(tag: T): string | false;
64
64
 
65
- declare function processTemplateParams(s: string, p: TemplateParams, sep: string): string;
65
+ declare function processTemplateParams(s: string, p: TemplateParams, sep: string, isJson?: boolean): string;
66
66
 
67
67
  declare function resolveTitleTemplate(template: string | ((title?: string) => string | null) | null, title?: string): string | null;
68
68
 
package/dist/index.mjs CHANGED
@@ -674,7 +674,7 @@ function tagDedupeKey(tag) {
674
674
  }
675
675
 
676
676
  const sepSub = "%separator";
677
- function sub(p, token) {
677
+ function sub(p, token, isJson = false) {
678
678
  let val;
679
679
  if (token === "s" || token === "pageTitle") {
680
680
  val = p.pageTitle;
@@ -684,10 +684,13 @@ function sub(p, token) {
684
684
  } else {
685
685
  val = p[token];
686
686
  }
687
- return val !== void 0 ? (val || "").replace(/"/g, '\\"') : void 0;
687
+ if (val !== void 0) {
688
+ return isJson ? (val || "").replace(/"/g, '\\"') : val || "";
689
+ }
690
+ return void 0;
688
691
  }
689
692
  const sepSubRe = new RegExp(`${sepSub}(?:\\s*${sepSub})*`, "g");
690
- function processTemplateParams(s, p, sep) {
693
+ function processTemplateParams(s, p, sep, isJson = false) {
691
694
  if (typeof s !== "string" || !s.includes("%"))
692
695
  return s;
693
696
  let decoded = s;
@@ -704,7 +707,7 @@ function processTemplateParams(s, p, sep) {
704
707
  if (token === sepSub || !tokens.includes(token)) {
705
708
  return token;
706
709
  }
707
- const re = sub(p, token.slice(1));
710
+ const re = sub(p, token.slice(1), isJson);
708
711
  return re !== void 0 ? re : token;
709
712
  }).trim();
710
713
  if (hasSepSub) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unhead/shared",
3
3
  "type": "module",
4
- "version": "1.11.10",
4
+ "version": "1.11.12",
5
5
  "author": "Harlan Wilton <harlan@harlanzw.com>",
6
6
  "license": "MIT",
7
7
  "funding": "https://github.com/sponsors/harlan-zw",
@@ -34,7 +34,7 @@
34
34
  "dist"
35
35
  ],
36
36
  "dependencies": {
37
- "@unhead/schema": "1.11.10"
37
+ "@unhead/schema": "1.11.12"
38
38
  },
39
39
  "devDependencies": {
40
40
  "packrup": "^0.1.2"