fix: URL-encode BOM numbers containing slashes

Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
dxc
2026-02-28 15:40:59 +08:00
parent 05fbb4e3b3
commit 54d83803c4

View File

@ -11,11 +11,11 @@ export function getBomList(params?: any) {
// 获取BOM详情 // 获取BOM详情
export function getBomDetail(bomNo: string) { export function getBomDetail(bomNo: string) {
// 去除首尾斜杠,并按 '/' 分割,取第一个有效部分 // 去除首尾斜杠,保留中间斜杠并进行 URL 编码
const trimmed = bomNo.replace(/^\/+|\/+$/g, ''); const trimmed = bomNo.replace(/^\/+|\/+$/g, '');
const firstPart = trimmed.split('/')[0]; const encoded = encodeURIComponent(trimmed);
return request({ return request({
url: `/v1/bom/detail/${firstPart}`, url: `/v1/bom/detail/${encoded}`,
method: 'get' method: 'get'
}) })
} }
@ -31,8 +31,11 @@ export function saveBom(data: any) {
// 删除BOM暂未实现预留 // 删除BOM暂未实现预留
export function deleteBom(bomNo: string) { export function deleteBom(bomNo: string) {
// 去除首尾斜杠,保留中间斜杠并进行 URL 编码
const trimmed = bomNo.replace(/^\/+|\/+$/g, '');
const encoded = encodeURIComponent(trimmed);
return request({ return request({
url: `/v1/bom/${bomNo}`, url: `/v1/bom/${encoded}`,
method: 'delete' method: 'delete'
}) })
} }