@symbo.ls/smbls-utils 3.8.2 → 3.8.7

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/cjs/index.js CHANGED
@@ -59,9 +59,10 @@ const removeChars = (str) => {
59
59
  return str.replace(/[^a-zA-Z0-9_]/g, "");
60
60
  };
61
61
  const toCamelCase = (str) => {
62
+ if (typeof str !== "string") str = String(str || "");
62
63
  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
63
64
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
64
- }).replaceAll(/\s+/g, "");
65
+ }).replace(/\s+/g, "");
65
66
  };
66
67
  const toTitleCase = (str) => str && str.replace(/\w\S*/g, (txt) => {
67
68
  return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
@@ -31,25 +31,7 @@ const escapeHtml = (text) => {
31
31
  const buildAttrs = (obj) => Object.entries(obj || {}).filter(([_, v]) => v !== void 0).map(([k, v]) => `${k}="${escapeHtml(v)}"`).join(" ");
32
32
  const generateMetaTags = (metadata, isProduction) => {
33
33
  if (!isProduction) {
34
- const faviconTag = (() => {
35
- const fv = metadata?.favicon || metadata?.favicons;
36
- if (!fv) return '<link rel="icon" href="/favicon.ico">';
37
- if (typeof fv === "string") return `<link rel="icon" href="${escapeHtml(fv)}">`;
38
- if (Array.isArray(fv)) {
39
- return fv.map(
40
- (item) => typeof item === "string" ? `<link rel="icon" href="${escapeHtml(item)}">` : `<link ${buildAttrs({ rel: "icon", ...item })}>`
41
- ).join("\n");
42
- }
43
- return `<link ${buildAttrs({ rel: "icon", ...fv })}>`;
44
- })();
45
- return [
46
- '<meta charset="UTF-8">',
47
- `<title>${escapeHtml(metadata.title || "Test")}</title>`,
48
- '<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">',
49
- '<meta name="robots" content="noindex">',
50
- '<meta name="apple-mobile-web-app-capable" content="yes">',
51
- faviconTag
52
- ].join("\n");
34
+ metadata = { ...metadata, robots: "noindex" };
53
35
  }
54
36
  const tags = Object.entries(metadata).reduce(
55
37
  (acc, [key, value]) => {
package/dist/esm/index.js CHANGED
@@ -28,9 +28,10 @@ const removeChars = (str) => {
28
28
  return str.replace(/[^a-zA-Z0-9_]/g, "");
29
29
  };
30
30
  const toCamelCase = (str) => {
31
+ if (typeof str !== "string") str = String(str || "");
31
32
  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
32
33
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
33
- }).replaceAll(/\s+/g, "");
34
+ }).replace(/\s+/g, "");
34
35
  };
35
36
  const toTitleCase = (str) => str && str.replace(/\w\S*/g, (txt) => {
36
37
  return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
@@ -7,25 +7,7 @@ const escapeHtml = (text) => {
7
7
  const buildAttrs = (obj) => Object.entries(obj || {}).filter(([_, v]) => v !== void 0).map(([k, v]) => `${k}="${escapeHtml(v)}"`).join(" ");
8
8
  const generateMetaTags = (metadata, isProduction) => {
9
9
  if (!isProduction) {
10
- const faviconTag = (() => {
11
- const fv = metadata?.favicon || metadata?.favicons;
12
- if (!fv) return '<link rel="icon" href="/favicon.ico">';
13
- if (typeof fv === "string") return `<link rel="icon" href="${escapeHtml(fv)}">`;
14
- if (Array.isArray(fv)) {
15
- return fv.map(
16
- (item) => typeof item === "string" ? `<link rel="icon" href="${escapeHtml(item)}">` : `<link ${buildAttrs({ rel: "icon", ...item })}>`
17
- ).join("\n");
18
- }
19
- return `<link ${buildAttrs({ rel: "icon", ...fv })}>`;
20
- })();
21
- return [
22
- '<meta charset="UTF-8">',
23
- `<title>${escapeHtml(metadata.title || "Test")}</title>`,
24
- '<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">',
25
- '<meta name="robots" content="noindex">',
26
- '<meta name="apple-mobile-web-app-capable" content="yes">',
27
- faviconTag
28
- ].join("\n");
10
+ metadata = { ...metadata, robots: "noindex" };
29
11
  }
30
12
  const tags = Object.entries(metadata).reduce(
31
13
  (acc, [key, value]) => {
@@ -586,25 +586,7 @@ var SmblsSmblsUtils = (() => {
586
586
  var buildAttrs = (obj) => Object.entries(obj || {}).filter(([_, v]) => v !== void 0).map(([k, v]) => `${k}="${escapeHtml(v)}"`).join(" ");
587
587
  var generateMetaTags = (metadata, isProduction) => {
588
588
  if (!isProduction) {
589
- const faviconTag = (() => {
590
- const fv = metadata?.favicon || metadata?.favicons;
591
- if (!fv) return '<link rel="icon" href="/favicon.ico">';
592
- if (typeof fv === "string") return `<link rel="icon" href="${escapeHtml(fv)}">`;
593
- if (Array.isArray(fv)) {
594
- return fv.map(
595
- (item) => typeof item === "string" ? `<link rel="icon" href="${escapeHtml(item)}">` : `<link ${buildAttrs({ rel: "icon", ...item })}>`
596
- ).join("\n");
597
- }
598
- return `<link ${buildAttrs({ rel: "icon", ...fv })}>`;
599
- })();
600
- return [
601
- '<meta charset="UTF-8">',
602
- `<title>${escapeHtml(metadata.title || "Test")}</title>`,
603
- '<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">',
604
- '<meta name="robots" content="noindex">',
605
- '<meta name="apple-mobile-web-app-capable" content="yes">',
606
- faviconTag
607
- ].join("\n");
589
+ metadata = { ...metadata, robots: "noindex" };
608
590
  }
609
591
  const tags = Object.entries(metadata).reduce(
610
592
  (acc, [key, value]) => {
@@ -894,9 +876,10 @@ var SmblsSmblsUtils = (() => {
894
876
  return str.replace(/[^a-zA-Z0-9_]/g, "");
895
877
  };
896
878
  var toCamelCase = (str) => {
879
+ if (typeof str !== "string") str = String(str || "");
897
880
  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function(word, index) {
898
881
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
899
- }).replaceAll(/\s+/g, "");
882
+ }).replace(/\s+/g, "");
900
883
  };
901
884
  var toTitleCase = (str) => str && str.replace(/\w\S*/g, (txt) => {
902
885
  return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@symbo.ls/smbls-utils",
3
- "version": "3.8.2",
3
+ "version": "3.8.7",
4
4
  "author": "symbo.ls",
5
5
  "files": [
6
6
  "dist",
@@ -32,8 +32,8 @@
32
32
  },
33
33
  "license": "CC-BY-NC-4.0",
34
34
  "dependencies": {
35
- "@domql/element": "^3.8.1",
36
- "@domql/utils": "^3.8.1"
35
+ "@domql/element": "^3.8.7",
36
+ "@domql/utils": "^3.8.7"
37
37
  },
38
38
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
39
39
  "browser": "./dist/esm/index.js",
package/src/index.js CHANGED
@@ -41,11 +41,12 @@ export const removeChars = (str) => {
41
41
  }
42
42
 
43
43
  export const toCamelCase = (str) => {
44
+ if (typeof str !== 'string') str = String(str || '')
44
45
  return str
45
46
  .replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
46
47
  return index === 0 ? word.toLowerCase() : word.toUpperCase()
47
48
  })
48
- .replaceAll(/\s+/g, '')
49
+ .replace(/\s+/g, '')
49
50
  }
50
51
 
51
52
  export const toTitleCase = (str) =>