io.bdeploy.common.cfg.RemoteValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
Public API including dependencies, ready to be used for integrations and plugins.
The newest version!
package io.bdeploy.common.cfg;
import io.bdeploy.common.cfg.Configuration.ConfigValidator;
import io.bdeploy.common.cfg.Configuration.ValidationMessage;
/**
* Checks if the given input is a valid remote reference.
*/
@ValidationMessage("Invalid remote: '%s'. A remote must be a local path or start with 'https://' and end with '/api'")
public class RemoteValidator implements ConfigValidator {
public static final String API_SUFFIX = "/api";
@Override
public boolean test(String value) {
String lower = value.toLowerCase();
// Allow local paths and file URLs
if (lower.startsWith("/") || lower.startsWith(".") || lower.startsWith("file:") || lower.startsWith("jar:file:")) {
return true;
}
return lower.startsWith("https://") && lower.endsWith(API_SUFFIX);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy