File tree Expand file tree Collapse file tree 2 files changed +4
-259
lines changed Expand file tree Collapse file tree 2 files changed +4
-259
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -46,23 +46,16 @@ import { isNotNullish } from './util';
46
46
* @returns {URL } 标准化后的URL对象
47
47
*/
48
48
export function normalizeURL ( location : string , base : URL ) : URL {
49
- // 流程节点1: 检查空输入
49
+ if ( location . startsWith ( '//' ) ) {
50
+ return new URL ( `http:${ location } ` ) ;
51
+ }
50
52
if ( ! location ) {
51
53
return new URL ( base ) ;
52
54
}
53
- // 流程节点2: 检查绝对路径(非协议路径)
54
- else if ( location . startsWith ( '/' ) && ! location . startsWith ( '//' ) ) {
55
- return new URL ( `.${ location } ` , base ) ;
56
- }
57
- // 流程节点3: 检查相对路径
58
- else if ( location . startsWith ( '.' ) ) {
59
- return new URL ( location , base ) ;
60
- }
61
- // 流程节点4: 尝试构建完整URL,失败则使用协议回退
62
55
try {
63
56
return new URL ( location ) ;
64
57
} catch {
65
- return new URL ( ` ${ base . protocol } // ${ location } ` ) ;
58
+ return new URL ( location , base ) ;
66
59
}
67
60
}
68
61
You can’t perform that action at this time.
0 commit comments