Fix pubkey exception for dotfiles

This commit is contained in:
crschnick
2026-05-25 09:33:21 +00:00
parent 7b1d0e574f
commit 81ec8b9a10
2 changed files with 7 additions and 1 deletions
@@ -61,7 +61,7 @@ public interface SshIdentityStrategy {
}
static FilePath getPublicKeyPath(FilePath file) {
if (file.getExtension().isEmpty()) {
if (file.getExtension().isEmpty() || file.isDotFile()) {
return FilePath.of(file + ".pub");
} else {
return FilePath.of(file.getBaseName() + ".pub");
@@ -117,6 +117,12 @@ public final class FilePath {
return components.getLast();
}
public boolean isDotFile() {
var name = getFileName();
var lastDot = name.lastIndexOf(".");
return lastDot == 0;
}
public FilePath getBaseName() {
var name = getFileName();
var lastDot = name.lastIndexOf(".");