Fix parseConnectionString for usernames with dashes (issue #264)

pull/285/head
Kelvin Schoofs 3 years ago
parent 239faaf54a
commit f05108a14e

@ -126,14 +126,14 @@ export function invalidConfigName(name: string) {
* - `user;abc=def,a-b=1-5@server.example.com:22/some/file.ext`
* - `user@server.example.com/directory`
* - `server:22/directory`
* - `user@server`
* - `test-user@server`
* - `server`
* - `@server/path` - Unlike OpenSSH, we allow a @ (and connection parameters) without a username
*
* The resulting FileSystemConfig will have as name basically the input, but without the path. If there is no
* username given, the name will start with `@`, as to differentiate between connection strings and config names.
*/
const CONNECTION_REGEX = /^((?<user>\w+)?(;[\w-]+=[\w\d-]+(,[\w\d-]+=[\w\d-]+)*)?@)?(?<host>[^@\\/:,=]+)(:(?<port>\d+))?(?<path>\/.*)?$/;
const CONNECTION_REGEX = /^((?<user>[\w\-._]+)?(;[\w-]+=[\w\d-]+(,[\w\d-]+=[\w\d-]+)*)?@)?(?<host>[^\s@\\/:,=]+)(:(?<port>\d+))?(?<path>\/\S*)?$/;
export function parseConnectionString(input: string): [config: FileSystemConfig, path?: string] | string {
input = input.trim();

@ -104,6 +104,8 @@ export interface FileSystemConfig extends ConnectConfig {
newFileMode?: number | string;
/** Whether this config was created from an instant connection string. Enables fuzzy matching for e.g. PuTTY, config-by-host, ... */
instantConnection?: boolean;
/** List of special flags to enable/disable certain fixes/features. Flags are usually used for issues or beta testing. Flags can disappear/change anytime! */
flags?: string[];
/** Internal property saying where this config comes from. Undefined if this config is merged or something */
_location?: ConfigLocation;
/** Internal property keeping track of where this config comes from (including merges) */
@ -124,14 +126,14 @@ export function invalidConfigName(name: string) {
* - `user;abc=def,a-b=1-5@server.example.com:22/some/file.ext`
* - `user@server.example.com/directory`
* - `server:22/directory`
* - `user@server`
* - `test-user@server`
* - `server`
* - `@server/path` - Unlike OpenSSH, we allow a @ (and connection parameters) without a username
*
* The resulting FileSystemConfig will have as name basically the input, but without the path. If there is no
* username given, the name will start with `@`, as to differentiate between connection strings and config names.
*/
const CONNECTION_REGEX = /^((?<user>\w+)?(;[\w-]+=[\w\d-]+(,[\w\d-]+=[\w\d-]+)*)?@)?(?<host>[^@\\/:,=]+)(:(?<port>\d+))?(?<path>\/.*)?$/;
const CONNECTION_REGEX = /^((?<user>[\w\-._]+)?(;[\w-]+=[\w\d-]+(,[\w\d-]+=[\w\d-]+)*)?@)?(?<host>[^\s@\\/:,=]+)(:(?<port>\d+))?(?<path>\/\S*)?$/;
export function parseConnectionString(input: string): [config: FileSystemConfig, path?: string] | string {
input = input.trim();

Loading…
Cancel
Save