@wovoon/polaris 0.4.1 → 0.4.2
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/client.js +14 -0
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -49,6 +49,20 @@ export class PolarisClient {
|
|
|
49
49
|
detectTarget() {
|
|
50
50
|
if (this.target)
|
|
51
51
|
return this.target;
|
|
52
|
+
const UUID = "[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}";
|
|
53
|
+
if (typeof location !== "undefined") {
|
|
54
|
+
// 隔离运行域:主机名首标签 static[-vN]-{deploymentId}(生产拓扑 pathname 是 /,路径正则提取不到)。
|
|
55
|
+
const firstLabel = String(location.hostname || "").split(".")[0] ?? "";
|
|
56
|
+
if (/^static-/.test(firstLabel)) {
|
|
57
|
+
const hostMatch = new RegExp(`-(${UUID})$`, "i").exec(firstLabel);
|
|
58
|
+
if (hostMatch)
|
|
59
|
+
return hostMatch[1];
|
|
60
|
+
}
|
|
61
|
+
// 平台启动片段:run-session 对所有拓扑统一注入 wovoon_app_id。
|
|
62
|
+
const hashMatch = new RegExp(`[?&#]wovoon_app_id=(${UUID})(?:&|$)`, "i").exec(String(location.hash || ""));
|
|
63
|
+
if (hashMatch)
|
|
64
|
+
return hashMatch[1];
|
|
65
|
+
}
|
|
52
66
|
const match = /\/api\/public\/static\/([0-9a-fA-F-]{36})/.exec(typeof location === "undefined" ? "" : location.pathname);
|
|
53
67
|
return match ? match[1] : "";
|
|
54
68
|
}
|