Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit303c02d

Browse files
committed
Improved image scanner
1 parent5f42af9 commit303c02d

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

‎src/main/java/generateimages/Main.java

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,25 @@ public static void main(String[] args) throws IOException, InterruptedException
4848
StringBuilderbuilder =newStringBuilder();
4949
// Extract and print all matched URLs
5050
while (matcher.find()) {
51-
StringfileName =matcher.group(3).substring(matcher.group(3).lastIndexOf('/') +1);
52-
ImageDownloader.downloadImage(matcher.group(1),
53-
file.getParent() +"/"
54-
+fileName);
55-
matcher.appendReplacement(builder,fileName);
51+
Stringgroup =matcher.group(3);
52+
intlasted =group ==null ? -1 :group.lastIndexOf('/');
53+
if (lasted >0 && !group.contains(":")) {
54+
StringfileName =group.substring(lasted +1).toLowerCase();
55+
if (fileName.endsWith(".png") ||fileName.endsWith(".jpg")
56+
||fileName.endsWith(".gif") ||fileName.endsWith(".svg")
57+
||matcher.group(1).contains("assets.")) {
58+
if (!fileName.contains(".")) {
59+
fileName =fileName +".png";
60+
}
61+
if (!Files.exists(Path.of(file.getParent() +"/"
62+
+fileName))) {
63+
ImageDownloader.downloadImage(matcher.group(1),
64+
file.getParent() +"/"
65+
+fileName);
66+
matcher.appendReplacement(builder,fileName);
67+
}
68+
}
69+
}
5670
}
5771
matcher.appendTail(builder);
5872
Files.writeString(file.toPath(),builder.toString(),UTF_8);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp