Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit 602ac5b

Browse files
committed
account for embed changes
1 parent 36a9678 commit 602ac5b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

common/src/main/java/io/github/axolotlclient/modules/screenshotUtils/ImageNetworking.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,17 @@
2929
import java.util.Base64;
3030
import java.util.Optional;
3131
import java.util.concurrent.CompletableFuture;
32+
import java.util.regex.Matcher;
33+
import java.util.regex.Pattern;
3234

3335
import io.github.axolotlclient.api.API;
3436
import io.github.axolotlclient.api.Constants;
3537
import io.github.axolotlclient.api.Request;
3638

3739
public abstract class ImageNetworking {
3840

41+
private static final Pattern URL_PATTERN = Pattern.compile("(?:.+/)?(\\d+)(?:/?.+)?");
42+
3943
public abstract void uploadImage(Path file);
4044

4145
protected CompletableFuture<String> upload(Path file) {
@@ -52,17 +56,18 @@ protected CompletableFuture<String> upload(String name, byte[] data) {
5256
}
5357

5458
protected static String idToUrl(String id) {
55-
return Request.Route.IMAGE.builder().path(id).path("raw").build().resolve().toString();
59+
return Request.Route.IMAGE.builder().path(id).path("view").build().resolve().toString();
5660
}
5761

5862
protected static Optional<String> urlToId(String url) {
5963
if (url.contains("/") && !url.startsWith(Constants.API_URL)) {
6064
return Optional.empty();
6165
}
62-
if (url.endsWith("/raw")) {
63-
url = url.substring(0, url.length() - 4);
66+
Matcher matcher = URL_PATTERN.matcher(url);
67+
if (!matcher.matches()) {
68+
return Optional.empty();
6469
}
65-
return Optional.of(url.substring(url.lastIndexOf("/") + 1));
70+
return Optional.of(matcher.group(1));
6671
}
6772

6873
protected static Optional<String> ensureUrl(String urlOrId) {

0 commit comments

Comments
 (0)