mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 14:15:24 +00:00
21 lines
623 B
JavaScript
21 lines
623 B
JavaScript
/**
|
|
* The login URL a server hands the desktop app goes to shell.openExternal,
|
|
* so only web pages pass: any other scheme (file:, smb:, ms-msdt:, ...)
|
|
* would launch whatever OS handler is registered for it.
|
|
*/
|
|
function isExternalLoginUrl(value) {
|
|
try {
|
|
const { protocol } = new URL(value);
|
|
return protocol === "https:" || protocol === "http:";
|
|
} catch {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/** A non-privileged port for the loopback callback listener. */
|
|
function isCallbackPort(value) {
|
|
return Number.isInteger(value) && value >= 1024 && value <= 65535;
|
|
}
|
|
|
|
module.exports = { isExternalLoginUrl, isCallbackPort };
|