diff --git a/packages/teleport/src/cluster/components/Sessions/SessionList/DescCell.tsx b/packages/teleport/src/cluster/components/Sessions/SessionList/DescCell.tsx index 4e4307bd91..16517d2750 100644 --- a/packages/teleport/src/cluster/components/Sessions/SessionList/DescCell.tsx +++ b/packages/teleport/src/cluster/components/Sessions/SessionList/DescCell.tsx @@ -23,14 +23,11 @@ import cfg from 'teleport/config'; export default function TypeCell(props: any) { const { rowIndex, data } = props; - const { sid, serverId, login, hostname } = data[rowIndex] as Session; + const { sid, login, hostname } = data[rowIndex] as Session; - // DELETE IN: 5.2 remove check for hostname. - // Older teleport versions do not set/retrieve hostname. - const nodeDesc = hostname || serverId; const url = cfg.getSshSessionRoute({ sid }); const theme = useTheme(); - const text = `Session is in progress [${login}@${nodeDesc}]`; + const text = `Session is in progress [${login}@${hostname}]`; return ( diff --git a/packages/teleport/src/cluster/components/Sessions/SessionList/NodeCell.tsx b/packages/teleport/src/cluster/components/Sessions/SessionList/NodeCell.tsx index 5dfd30100d..34139951be 100644 --- a/packages/teleport/src/cluster/components/Sessions/SessionList/NodeCell.tsx +++ b/packages/teleport/src/cluster/components/Sessions/SessionList/NodeCell.tsx @@ -20,14 +20,12 @@ import { Session } from 'teleport/services/ssh'; export default function DescCell(props: any) { const { rowIndex, data } = props; - const { hostname, addr, serverId } = data[rowIndex] as Session; - // DELETE IN: 5.2 remove check for hostname/addr. - // Older teleport versions do not set/retrieve hostname or addr. - const nodeName = hostname || serverId; + const { hostname, addr } = data[rowIndex] as Session; const nodeAddr = addr ? `[${addr}]` : ''; + return ( - {nodeName} {nodeAddr} + {hostname} {nodeAddr} ); } diff --git a/packages/teleport/src/components/NodeList/NodeList.tsx b/packages/teleport/src/components/NodeList/NodeList.tsx index 91e6dc92d6..3b5f6c492f 100644 --- a/packages/teleport/src/components/NodeList/NodeList.tsx +++ b/packages/teleport/src/components/NodeList/NodeList.tsx @@ -129,8 +129,8 @@ const LoginCell: React.FC> = props => { const { rowIndex, data, onOpen, onSelect } = props; - const { hostname, id } = data[rowIndex] as Node; - const serverId = hostname || id; + const { id } = data[rowIndex] as Node; + const serverId = id; function handleOnOpen() { return onOpen(serverId); } diff --git a/packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx b/packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx index 0b2afa038a..3ff8bfb056 100644 --- a/packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx +++ b/packages/teleport/src/components/QuickLaunch/QuickLaunch.jsx @@ -63,14 +63,11 @@ export default function FieldInputSsh({ ); } -// SSH_STR_REGEX is a modified regex from teleport's lib/sshutils/scp/scp.go. -// Captures two named groups: username and host. -const SSH_STR_REGEX = /(?:(?[-.\w@]+)@)(?[-.\w]+)$/; +// Checks for spaces between chars, and +// captures two named groups: username and host. +const SSH_STR_REGEX = /^(?:(?[^\s]+)@)(?[^\s]+)$/; const check = value => { - const hasWhiteSpace = /\s/.test(value); - if (!hasWhiteSpace) { - return SSH_STR_REGEX.exec(value); - } + return SSH_STR_REGEX.exec(value.trim()); }; const StyledInput = styled(Input)( diff --git a/packages/teleport/src/console/stores/storeDocs.ts b/packages/teleport/src/console/stores/storeDocs.ts index bbcea0224e..4265563514 100644 --- a/packages/teleport/src/console/stores/storeDocs.ts +++ b/packages/teleport/src/console/stores/storeDocs.ts @@ -82,7 +82,7 @@ export default class StoreDocs extends Store { } findByUrl(url: string) { - return this.state.items.find(i => i.url === url); + return this.state.items.find(i => i.url === encodeURI(url)); } getNodeDocuments() {