Skip to content

Commit

Permalink
[pushbullet] Replace deprecated URL constructor
Browse files Browse the repository at this point in the history
Signed-off-by: jsetton <[email protected]>
  • Loading branch information
jsetton committed Dec 28, 2024
1 parent d049995 commit 6d8b9f6
Showing 1 changed file with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import static org.openhab.binding.pushbullet.internal.PushbulletBindingConstants.*;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
Expand Down Expand Up @@ -279,13 +278,9 @@ private boolean sendPush(PushRequest request) {
if (content.startsWith("data:")) {
return IMAGE_FILE_NAME;
}
try {
Path fileName = Path.of(content.startsWith("http") ? new URL(content).getPath() : content).getFileName();
if (fileName != null) {
return fileName.toString();
}
} catch (MalformedURLException e) {
logger.debug("Malformed url content: {}", e.getMessage());
Path fileName = Path.of(content.startsWith("http") ? URI.create(content).getPath() : content).getFileName();
if (fileName != null) {
return fileName.toString();
}
return null;
}
Expand Down

0 comments on commit 6d8b9f6

Please sign in to comment.