Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pac
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tools
pac
Commits
07e47a65
Commit
07e47a65
authored
Aug 23, 2026
by
luoqi
Browse files
Options
Browse Files
Download
Plain Diff
merge: 宿主跳转按子串换域名(arrail-test 也认) → main
parents
ec5fb5e5
8827ac0b
Pipeline
#3595
failed in 0 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
8 deletions
+31
-8
apps/pac-web/src/lib/host-brand-url.test.ts
+13
-0
apps/pac-web/src/lib/host-brand-url.ts
+18
-8
No files found.
apps/pac-web/src/lib/host-brand-url.test.ts
View file @
07e47a65
...
@@ -6,6 +6,19 @@ import { applyBrandHost } from './host-brand-url';
...
@@ -6,6 +6,19 @@ import { applyBrandHost } from './host-brand-url';
* 诊所级用户的 sourceUnits 是哨兵 `__pac_deny_no_brand__`,判不出品牌)。
* 诊所级用户的 sourceUnits 是哨兵 `__pac_deny_no_brand__`,判不出品牌)。
*/
*/
describe
(
'瑞泰患者:arrail → rytime'
,
()
=>
{
describe
(
'瑞泰患者:arrail → rytime'
,
()
=>
{
/**
* 🔴 2026-08-23 测试环境实测栽的那条:域名是 `arrail-test.5i5ya.com`,
* 按域名标签精确匹配**匹配不上**,一个字都没换。各环境前缀带后缀(test/uat/…)枚举不完。
*/
test
(
'⭐⭐ 带环境后缀的域名照样换(arrail-test → rytime-test)'
,
()
=>
{
expect
(
applyBrandHost
(
'https://arrail-test.5i5ya.com/user/login'
,
'瑞泰'
)).
toBe
(
'https://rytime-test.5i5ya.com/user/login'
,
);
expect
(
applyBrandHost
(
'https://arrail-test.5i5ya.com/customerInfo?userId=1'
,
'瑞泰'
),
).
toBe
(
'https://rytime-test.5i5ya.com/customerInfo?userId=1'
);
});
test
(
'⭐⭐ 普通跳转链接换域名'
,
()
=>
{
test
(
'⭐⭐ 普通跳转链接换域名'
,
()
=>
{
expect
(
expect
(
applyBrandHost
(
'https://arrail.5i5ya.com/customerInfo?userId=123&fileNumber=SH01'
,
'瑞泰'
),
applyBrandHost
(
'https://arrail.5i5ya.com/customerInfo?userId=123&fileNumber=SH01'
,
'瑞泰'
),
...
...
apps/pac-web/src/lib/host-brand-url.ts
View file @
07e47a65
...
@@ -36,7 +36,7 @@ const BRAND_HOST_SEGMENT: Record<string, string> = {
...
@@ -36,7 +36,7 @@ const BRAND_HOST_SEGMENT: Record<string, string> = {
瑞泰
:
'rytime'
,
瑞泰
:
'rytime'
,
};
};
/** 本替换认得的所有品牌片段
(用于识别"这个域名是别的品牌的")
。 */
/** 本替换认得的所有品牌片段。 */
const
KNOWN_SEGMENTS
=
Object
.
values
(
BRAND_HOST_SEGMENT
);
const
KNOWN_SEGMENTS
=
Object
.
values
(
BRAND_HOST_SEGMENT
);
/**
/**
...
@@ -45,6 +45,15 @@ const KNOWN_SEGMENTS = Object.values(BRAND_HOST_SEGMENT);
...
@@ -45,6 +45,15 @@ const KNOWN_SEGMENTS = Object.values(BRAND_HOST_SEGMENT);
* @param url 已填好占位符的宿主地址,或 `HOST_ORIGIN` 那样的裸 origin
* @param url 已填好占位符的宿主地址,或 `HOST_ORIGIN` 那样的裸 origin
* @param sourceUnit 患者所属品牌名(`patient.sourceUnit`);null / 未知品牌 → 原样返回
* @param sourceUnit 患者所属品牌名(`patient.sourceUnit`);null / 未知品牌 → 原样返回
*
*
* 🔴 **按子串替换,⛔ 不按域名标签精确匹配**(2026-08-23 测试环境实测栽过)。
* 第一版写的是"把 hostname 拆成标签、找等于 `arrail` 的那一段" —— 测试环境的域名是
* `arrail-test.5i5ya.com`,标签是 `arrail-test`,精确匹配**匹配不上**,一个字都没换,
* 瑞泰患者照样被带去瑞尔门户。而各环境的域名前缀是会带后缀的(test / uat / …),
* 枚举不完。⇒ 认这个**词**本身,不认它周围是什么。
* ⚠️ 仍然只在 URL 解得出来时换 **hostname**,⛔ 不碰路径和查询串:
* `?from=arrail` 是宿主自己的业务参数,替换它属于越界。
* ⚠️ 解不出 URL(相对路径 / 哨兵值 'postMessage')→ 原样返回。
*
* 返回值恒非空(拿不准就返回原值)—— ⛔ 这条补丁不许把一个本来能用的链接变没。
* 返回值恒非空(拿不准就返回原值)—— ⛔ 这条补丁不许把一个本来能用的链接变没。
*/
*/
export
function
applyBrandHost
(
export
function
applyBrandHost
(
...
@@ -62,12 +71,13 @@ export function applyBrandHost(
...
@@ -62,12 +71,13 @@ export function applyBrandHost(
return
url
;
// 相对路径、哨兵值('postMessage')等 —— 没有域名可换
return
url
;
// 相对路径、哨兵值('postMessage')等 —— 没有域名可换
}
}
// 域名里已经是目标品牌 → 不动(幂等)
// 域名里出现的**别的**品牌片段,整词换成本品牌的(arrail-test → rytime-test)
const
parts
=
u
.
hostname
.
split
(
'.'
);
let
host
=
u
.
hostname
;
const
idx
=
parts
.
findIndex
((
p
)
=>
KNOWN_SEGMENTS
.
includes
(
p
));
for
(
const
seg
of
KNOWN_SEGMENTS
)
{
if
(
idx
<
0
||
parts
[
idx
]
===
want
)
return
url
;
if
(
seg
===
want
)
continue
;
host
=
host
.
split
(
seg
).
join
(
want
);
parts
[
idx
]
=
want
;
}
u
.
hostname
=
parts
.
join
(
'.'
);
if
(
host
===
u
.
hostname
)
return
url
;
// 没什么可换 → 原样(幂等)
u
.
hostname
=
host
;
return
u
.
toString
();
return
u
.
toString
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment