fix(gitops): clean trailing slash [EE-6346] (#10777)
Co-authored-by: testa113 <testa113>pull/10807/head
parent
a2d6d6002c
commit
4e8b371fb7
|
@ -9,13 +9,13 @@ import UpToDate from '@/assets/ico/icon_up-to-date.svg?c';
|
|||
import { isoDateFromTimestamp } from '@/portainer/filters/filters';
|
||||
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
|
||||
import { getDashboardRoute } from '@/react/portainer/environments/utils';
|
||||
import { cleanGitRepoUrl } from '@/react/portainer/gitops/utils';
|
||||
|
||||
import { Button } from '@@/buttons';
|
||||
import { Icon } from '@@/Icon';
|
||||
import { Link } from '@@/Link';
|
||||
|
||||
import { DeploymentStatus, EdgeStackStatus, StatusType } from '../../types';
|
||||
import { removeTrailingGitExtension } from '../../utils';
|
||||
|
||||
import { EnvironmentActions } from './EnvironmentActions';
|
||||
import { ActionStatus } from './ActionStatus';
|
||||
|
@ -188,9 +188,9 @@ function TargetVersionCell({
|
|||
{row.original.TargetCommitHash ? (
|
||||
<div>
|
||||
<a
|
||||
href={`${removeTrailingGitExtension(
|
||||
row.original.GitConfigURL
|
||||
)}/commit/${row.original.TargetCommitHash}`}
|
||||
href={`${cleanGitRepoUrl(row.original.GitConfigURL)}/commit/${
|
||||
row.original.TargetCommitHash
|
||||
}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -239,9 +239,9 @@ function DeployedVersionCell({
|
|||
<div>
|
||||
{statusIcon}
|
||||
<a
|
||||
href={`${removeTrailingGitExtension(
|
||||
row.original.GitConfigURL
|
||||
)}/commit/${row.original.TargetCommitHash}`}
|
||||
href={`${cleanGitRepoUrl(row.original.GitConfigURL)}/commit/${
|
||||
row.original.TargetCommitHash
|
||||
}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
|
|
@ -3,12 +3,12 @@ import _ from 'lodash';
|
|||
|
||||
import { isoDateFromTimestamp } from '@/portainer/filters/filters';
|
||||
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
|
||||
import { cleanGitRepoUrl } from '@/react/portainer/gitops/utils';
|
||||
|
||||
import { buildNameColumn } from '@@/datatables/buildNameColumn';
|
||||
import { Link } from '@@/Link';
|
||||
|
||||
import { StatusType } from '../../types';
|
||||
import { removeTrailingGitExtension } from '../../utils';
|
||||
|
||||
import { EdgeStackStatus } from './EdgeStacksStatus';
|
||||
import { DecoratedEdgeStack } from './types';
|
||||
|
@ -147,9 +147,9 @@ export const columns = _.compact([
|
|||
<div className="text-center">
|
||||
<a
|
||||
target="_blank"
|
||||
href={`${removeTrailingGitExtension(
|
||||
item.GitConfig.URL
|
||||
)}/commit/${item.GitConfig.ConfigHash}`}
|
||||
href={`${cleanGitRepoUrl(item.GitConfig.URL)}/commit/${
|
||||
item.GitConfig.ConfigHash
|
||||
}`}
|
||||
rel="noreferrer"
|
||||
>
|
||||
{item.GitConfig.ConfigHash.slice(0, 7)}
|
||||
|
|
|
@ -19,8 +19,3 @@ export function getValidEditorTypes(
|
|||
? _.intersection(...endpointTypes.map((type) => right[type]))
|
||||
: [EditorType.Compose, EditorType.Kubernetes];
|
||||
}
|
||||
|
||||
export function removeTrailingGitExtension(url: string) {
|
||||
// the url could have the .git extension. Remove it if it does.
|
||||
return url.replace(/\.git$/, '');
|
||||
}
|
||||
|
|
|
@ -32,3 +32,10 @@ export function confirmEnableTLSVerify() {
|
|||
'Enabling the verification of TLS certificates without ensuring the correct configuration of your Certificate Authority (CA) for self-signed certificates can result in deployment failures.',
|
||||
});
|
||||
}
|
||||
|
||||
export function cleanGitRepoUrl(url: string) {
|
||||
return url
|
||||
.trim() // remove leading and trailing whitespace
|
||||
.replace(/\/$/, '') // if there's a trailing slash, remove it
|
||||
.replace(/\.git$/, ''); // if there's a trailing .git extension, remove it
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue