Skip to content

Commit e8fc377

Browse files
committed
Add url decoer to handler file names with spaces
1 parent cdf8249 commit e8fc377

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cli/src/main/java/dev/starfix/Starfix.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
import picocli.CommandLine.ExitCode;
1515
import picocli.CommandLine.Parameters;
1616

17+
import java.io.UnsupportedEncodingException;
1718
import java.io.BufferedReader;
1819
import java.io.IOException;
1920
import java.io.InputStreamReader;
2021
import java.net.URI;
22+
import java.net.URLDecoder;
2123
import java.nio.file.Files;
2224
import java.nio.file.Path;
2325
import java.nio.file.Paths;
@@ -43,7 +45,12 @@ public int config() throws Exception {
4345

4446
@Command(name = "clone")
4547
public int cloneCmd(@Parameters(index = "0") String url) {
46-
48+
try{
49+
url = URLDecoder.decode(url,"UTF-8");
50+
}catch(UnsupportedEncodingException e){
51+
throw new IllegalStateException(e.getMessage(), e);
52+
}
53+
4754
if (url.startsWith("ide://")) {
4855
// stripping out ide:// to simplify launcher scripts.
4956
url = url.substring(6);
@@ -88,7 +95,7 @@ public int cloneCmd(@Parameters(index = "0") String url) {
8895
if(isBlob(url))
8996
{ // Example URL : https://github.com/starfixdev/starfix/blob/master/cli/pom.xml
9097
// Example URL2: https://github.com/hexsum/Mojo-Webqq/blob/master/script/check_dependencies.pl#L17
91-
98+
System.out.println(url);
9299
String temp = url.substring(url.indexOf("blob/")+5);
93100
branch = temp.substring(0,temp.indexOf("/"));
94101
filePath = temp.substring(temp.indexOf("/")+1);

0 commit comments

Comments
 (0)