Skip to content

Commit 6e99186

Browse files
committed
create src\shared\string\stringUtils.js to remove duplicates
1 parent c9fe6e5 commit 6e99186

5 files changed

Lines changed: 15 additions & 19 deletions

File tree

src/engine/debug/panels/PromotionGatePanel.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ PromotionGatePanel.js
88
import { drawPanel } from '../DebugPanel.js';
99

1010
function asObject(value) {
11-
return value && typeof value === 'object' && !Array.isArray(value) ? value : {};
11+
return value && typeof value === 'object' && !Array.isArray(value)
12+
? value
13+
: {};
1214
}
1315

1416
function resolvePromotionStatus(source) {

src/shared/string/stringUtil.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
3+
export function escapeHtml(value) {
4+
return String(value || "")
5+
.replaceAll("&", "&")
6+
.replaceAll("<", "&lt;")
7+
.replaceAll(">", "&gt;")
8+
.replaceAll('"', "&quot;")
9+
.replaceAll("'", "&#39;");
10+
}

tools/renderToolsIndex.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import { getToolRegistry } from "./toolRegistry.js";
2-
3-
function escapeHtml(value) {
4-
return String(value || "")
5-
.replaceAll("&", "&amp;")
6-
.replaceAll("<", "&lt;")
7-
.replaceAll(">", "&gt;")
8-
.replaceAll('"', "&quot;")
9-
.replaceAll("'", "&#39;");
10-
}
2+
import { escapeHtml } from "../src/shared/string/stringUtil.js";
113

124
function renderToolCard(tool) {
135
const sampleLinks = Array.isArray(tool.sampleEntryPoints) && tool.sampleEntryPoints.length > 0

tools/shared/platformShell.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,10 @@ import {
55
readSharedPaletteHandoff
66
} from "./assetUsageIntegration.js";
77
import { createProjectSystemController } from "./projectSystem.js";
8+
import { escapeHtml } from "../../src/shared/string/stringUtil.js";
89

910
let projectController = null;
1011

11-
function escapeHtml(value) {
12-
return String(value ?? "")
13-
.replaceAll("&", "&amp;")
14-
.replaceAll("<", "&lt;")
15-
.replaceAll(">", "&gt;")
16-
.replaceAll('"', "&quot;")
17-
.replaceAll("'", "&#39;");
18-
}
19-
2012
function getPageMode() {
2113
return document.body.dataset.toolsPlatformPage || "tool";
2214
}
56 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)