Skip to content

Commit 0f8e0d6

Browse files
committed
[#9] v3.0.4: Hotfix
1 parent 0f247c1 commit 0f8e0d6

File tree

3 files changed

+35
-25
lines changed

3 files changed

+35
-25
lines changed

package-lock.json

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dr.pogodin/react-helmet",
3-
"version": "3.0.3",
3+
"version": "3.0.4",
44
"description": "Thread-safe Helmet for React 19+ and friends",
55
"main": "./build/common/index.js",
66
"module": "./build/module/index.js",

src/server.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,17 @@ function generateTagsAsString<T>(
8888
if (!(name === TAG_PROPERTIES.INNER_HTML as string
8989
|| name === TAG_PROPERTIES.CSS_TEXT as string)) {
9090
const attrName = HTML_TAG_MAP[name] ?? name;
91-
const attr = value === undefined ? attrName : `${attrName}="${encodeSpecialCharacters(value as string, encode)}"`;
91+
92+
let attr: string;
93+
if (value === undefined) attr = attrName;
94+
else {
95+
// Perhaps, if `value` is not a string we should just do
96+
// "attr = attrName", as in the case just above. Playing
97+
// it safe now, to avoid changes from the original code.
98+
const valStr = typeof value === 'string' ? value : String(value);
99+
attr = `${attrName}="${encodeSpecialCharacters(valStr, encode)}"`;
100+
}
101+
92102
if (attributeHtml) attributeHtml += ` ${attr}`;
93103
else attributeHtml = attr;
94104
}

0 commit comments

Comments
 (0)