@@ -12,7 +12,7 @@ use url::Url;
1212use crate :: {
1313 downloader:: { DownloadOptions , DownloadState , Downloader } ,
1414 error:: { DownloadError , PlatformError } ,
15- utils:: { matches_pattern, should_fallback} ,
15+ utils:: { decode_uri , matches_pattern, should_fallback} ,
1616} ;
1717
1818pub enum ApiType {
@@ -29,11 +29,13 @@ pub enum PlatformUrl {
2929}
3030
3131static GITHUB_RELEASE_RE : LazyLock < Regex > = LazyLock :: new ( || {
32- Regex :: new ( r"^(?i)(?:https?://)?(?:github(?:\.com)?[:/])([^/@]+/[^/@]+)(?:@([^/\s]*)?)?$" )
33- . unwrap ( )
32+ Regex :: new (
33+ r"^(?i)(?:https?://)?(?:github(?:\.com)?[:/])([^/@]+/[^/@]+)(?:@([^/\s]+(?:/[^/\s]*)*)?)?$" ,
34+ )
35+ . unwrap ( )
3436} ) ;
3537static GITLAB_RELEASE_RE : LazyLock < Regex > = LazyLock :: new ( || {
36- Regex :: new ( r"^(?i)(?:https?://)?(?:gitlab(?:\.com)?[:/])((?:\d+)|(?:[^/@]+(?:/[^/@]+)*))(?:@([^/\s]*)?)?$" )
38+ Regex :: new ( r"^(?i)(?:https?://)?(?:gitlab(?:\.com)?[:/])((?:\d+)|(?:[^/@]+(?:/[^/@]+)*))(?:@([^/\s]+(?:/[^/\s]*) *)?)?$" )
3739 . unwrap ( )
3840} ) ;
3941
@@ -48,8 +50,9 @@ impl PlatformUrl {
4850 let project = caps. get ( 1 ) . unwrap ( ) . as_str ( ) ;
4951 let tag = caps
5052 . get ( 2 )
51- . map ( |tag| tag. as_str ( ) . trim ( ) )
52- . filter ( |& tag| !tag. is_empty ( ) ) ;
53+ . map ( |tag| tag. as_str ( ) . trim_matches ( & [ '\'' , '"' , ' ' ] [ ..] ) )
54+ . filter ( |& tag| !tag. is_empty ( ) )
55+ . map ( decode_uri) ;
5356 if let Some ( tag) = tag {
5457 return Ok ( PlatformUrl :: Github ( format ! ( "{}@{}" , project, tag) ) ) ;
5558 } else {
@@ -67,8 +70,9 @@ impl PlatformUrl {
6770 }
6871 let tag = caps
6972 . get ( 2 )
70- . map ( |tag| tag. as_str ( ) . trim ( ) )
71- . filter ( |& tag| !tag. is_empty ( ) ) ;
73+ . map ( |tag| tag. as_str ( ) . trim_matches ( & [ '\'' , '"' , ' ' ] [ ..] ) )
74+ . filter ( |& tag| !tag. is_empty ( ) )
75+ . map ( decode_uri) ;
7276 if let Some ( tag) = tag {
7377 return Ok ( PlatformUrl :: Gitlab ( format ! ( "{}@{}" , project, tag) ) ) ;
7478 } else {
0 commit comments