Skip to content

Commit c4c9833

Browse files
committed
Improved url generation
1 parent c20ba3e commit c4c9833

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/main/java/generateimages/Main.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
public class Main {
1616
private static final String URL_REGEX = "(https?://[\\w-]+(\\.[\\w-]+)+(/[^\\s)]*)?)";
1717
private static final Pattern PATTERN = Pattern.compile(URL_REGEX);
18+
private static final String GROUP_AND_SOLUTION_REGEX = "(g[^\\\\]+\\\\s[^\\\\]+)";
19+
private static final Pattern PATTERN_G_AND_S = Pattern.compile(GROUP_AND_SOLUTION_REGEX);
1820

1921
private static void fillFilesRecursively(Path directory, final List<File> resultFiles)
2022
throws IOException {
@@ -64,6 +66,11 @@ public static void main(String[] args) throws IOException, InterruptedException
6466
ImageDownloader.downloadImage(
6567
matcher.group(1), file.getParent() + "/" + fileName);
6668
}
69+
Matcher matcher2 = PATTERN_G_AND_S.matcher(file.getAbsolutePath());
70+
if (matcher2.find()) {
71+
fileName = "https://leetcode-in-java.github.io/src/main/java/"
72+
+ matcher2.group(1).replace("\\", "/") + "/" + fileName;
73+
}
6774
matcher.appendReplacement(builder, fileName);
6875
}
6976
}

0 commit comments

Comments
 (0)