File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -131,13 +131,20 @@ void TUrl::SetUrl(const char *url, Bool_t defaultIsFile)
131131 fHostFQ = " " ;
132132
133133 // if url starts with a / consider it as a file url
134- if (url[0 ] == ' /' )
134+ if (url[0 ] == ' /' ) {
135135 defaultIsFile = kTRUE ;
136+ // ROOT-5430: if url starts with two slashes but
137+ // not three slashes, just remove the first of them
138+ if (strlen (url) > 2 && url[1 ] == ' /' && url[2 ] != ' /' ) {
139+ url = &url[1 ];
140+ }
141+ }
136142
137143 // Find protocol
138144 char *s, sav;
139145
140146 TString surl = url;
147+
141148 char *u, *u0 = Strip (defaultIsFile && surl.EndsWith (" :/" ) ? TString (surl (0 ,surl.Length ()-2 )).Data () : url);
142149tryfile:
143150 u = u0;
Original file line number Diff line number Diff line change @@ -12,4 +12,10 @@ TEST(TUrl, FilePath)
1212 // https://its.cern.ch/jira/browse/ROOT-5820
1313 TUrl u2 (" /tmp/a.root:/" , kTRUE ); // TFile.GetPath() returns a trailing :/
1414 EXPECT_TRUE (u2.IsValid ());
15+
16+ // ROOT-5430
17+ const char * ref_5430 = " file:///tmp/t.root" ;
18+ EXPECT_STREQ (TUrl (" /tmp/t.root" ).GetUrl (), ref_5430);
19+ EXPECT_STREQ (TUrl (" //tmp/t.root" ).GetUrl (), ref_5430);
20+ EXPECT_STREQ (TUrl (" ///tmp/t.root" ).GetUrl (), ref_5430);
1521}
You can’t perform that action at this time.
0 commit comments