Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: you can use your hostname for the remote now #32

Merged
merged 1 commit into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions src/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,18 @@ export const askForMnemonicInput = async (): Promise<any> => {
return inquirer.prompt(questions);
};

const hostPattern = /^[a-zA-Z0-9.-]+(:[0-9]{1,5})?$/;

const validateHost = (input: string): boolean | string => {
if (hostPattern.test(input)) {
// Regex pattern for validating hostnames (e.g., example.com) without ports
const hostPattern = /^(?!:\/\/)([a-zA-Z0-9.-]+)$/; // For hostnames without port
// Regex pattern for validating IPv4 addresses (e.g., 192.168.0.1) without ports
const ipPattern = /^(?!:\/\/)(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/; // For IPv4 without port

// Check if the input matches either a hostname or an IP address
if (hostPattern.test(input) || ipPattern.test(input)) {
return true;
}
return 'Please enter a valid host (e.g., example.com or example.com:8080)';

return 'Please enter a valid IP address or host without a port (e.g., example.com or 192.168.0.1)';
};

export const promptForRemote = async (): Promise<string> => {
Expand Down
Loading