File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ describe("repoUrl", () => {
9595 it ( "规范化常见仓库地址" , ( ) => {
9696 expect ( repoUrl ( "git+https://github.com/foo/bar.git" ) ) . toBe ( "https://github.com/foo/bar" ) ;
9797 expect ( repoUrl ( "git+ssh://git@github.com/foo/bar.git" ) ) . toBe (
98- "https://git@ github.com/foo/bar" ,
98+ "https://github.com/foo/bar" ,
9999 ) ;
100100 expect ( repoUrl ( "git://github.com/foo/bar.git" ) ) . toBe ( "https://github.com/foo/bar" ) ;
101101 expect ( repoUrl ( { url : "https://github.com/foo/bar" } ) ) . toBe (
Original file line number Diff line number Diff line change @@ -12,11 +12,9 @@ export function repoUrl(repository: RegistryManifest["repository"]) {
1212 if ( ! repository ) return undefined ;
1313 const url = typeof repository === "string" ? repository : repository . url ;
1414 if ( ! url ) return undefined ;
15- if ( / ^ g i t ( \+ s s h ) ? : \/ \/ / . test ( url ) ) {
16- return url . replace ( / ^ g i t ( \+ s s h ) ? : \/ \/ / , "https://" ) . replace ( / \. g i t $ / , "" ) ;
17- }
18- if ( / ^ g i t \+ h t t p s ? : \/ \/ / . test ( url ) ) {
19- return url . replace ( / ^ g i t \+ h t t p s ? : \/ \/ / , "https://" ) . replace ( / \. g i t $ / , "" ) ;
15+ if ( / ^ g i t ( \+ s s h | \+ h t t p s ? ) ? : \/ \/ / . test ( url ) ) {
16+ const rest = url . replace ( / ^ g i t ( \+ s s h | \+ h t t p s ? ) ? : \/ \/ / , "" ) . replace ( / ^ [ ^ @ ] + @ / , "" ) ;
17+ return `https://${ rest } ` . replace ( / \. g i t $ / , "" ) ;
2018 }
2119 if ( / ^ g i t @ g i t h u b \. c o m : ( .+ ) $ / . test ( url ) ) {
2220 return `https://github.com/${ url . replace ( / ^ g i t @ g i t h u b \. c o m : / , "" ) . replace ( / \. g i t $ / , "" ) } ` ;
Original file line number Diff line number Diff line change @@ -98,7 +98,22 @@ function CnpmPkgInner({ rest }: { rest?: string }) {
9898 ) ;
9999 }
100100
101- if ( ! manifest ?. name ) return null ;
101+ if ( ! manifest ?. name ) {
102+ return (
103+ < Layout >
104+ < PageContainer className = "py-6" >
105+ < Alert variant = "destructive" >
106+ < AlertDescription className = "flex items-center justify-between gap-3" >
107+ 未能读取到 { name } 的包信息
108+ < Button type = "button" variant = "outline" size = "sm" onClick = { retry } >
109+ 重试
110+ </ Button >
111+ </ AlertDescription >
112+ </ Alert >
113+ </ PageContainer >
114+ </ Layout >
115+ ) ;
116+ }
102117
103118 const requestedVersion = params . get ( "version" ) || "" ;
104119 const fallbackVersion = sortVersions ( manifest . versions ) [ 0 ] ?. version ;
You can’t perform that action at this time.
0 commit comments