[pushbullet] Replace deprecated URL constructor (#17982)

Signed-off-by: Jeremy Setton <jeremy.setton@gmail.com>
This commit is contained in:
Jeremy 2024-12-28 20:02:33 -05:00 committed by GitHub
parent df1ee5fda3
commit 33b19419b6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -15,8 +15,8 @@ package org.openhab.binding.pushbullet.internal.handler;
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.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collection;
@ -280,11 +280,11 @@ public class PushbulletHandler extends BaseThingHandler {
return IMAGE_FILE_NAME;
}
try {
Path fileName = Path.of(content.startsWith("http") ? new URL(content).getPath() : content).getFileName();
Path fileName = Path.of(content.startsWith("http") ? new URI(content).getPath() : content).getFileName();
if (fileName != null) {
return fileName.toString();
}
} catch (MalformedURLException e) {
} catch (URISyntaxException e) {
logger.debug("Malformed url content: {}", e.getMessage());
}
return null;