File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -47,6 +47,15 @@ import { usePushesQuery } from '../../query/usePushesQuery';
4747import { useMutation , useQueryClient } from '@tanstack/react-query' ;
4848import { repoQueryKeys } from '../../query/repoQueryKeys' ;
4949
50+ const isGitHubUrl = ( url : string | undefined ) : boolean => {
51+ try {
52+ const { hostname } = new URL ( url ?? '' ) ;
53+ return hostname === 'github.com' || hostname . endsWith ( '.github.com' ) ;
54+ } catch {
55+ return false ;
56+ }
57+ } ;
58+
5059const RepoDetails = ( ) => {
5160 const navigate = useNavigate ( ) ;
5261 const [ searchParams , setSearchParams ] = useSearchParams ( ) ;
@@ -140,8 +149,8 @@ const RepoDetails = () => {
140149 const parsedUrl = new URL ( remoteUrl ) ;
141150 const cloneURL = `${ proxyURL } /${ parsedUrl . host } ${ parsedUrl . port ? `:${ parsedUrl . port } ` : '' } ${ parsedUrl . pathname } ` ;
142151 const orgHref = remoteRepoData ?. profileUrl ;
143- const repoHref = remoteRepoData ?. htmlUrl ?. includes ( 'github.com' )
144- ? remoteRepoData . htmlUrl
152+ const repoHref = isGitHubUrl ( remoteRepoData ?. htmlUrl )
153+ ? remoteRepoData ? .htmlUrl
145154 : trimTrailingDotGit ( repo . url ) ;
146155
147156 return (
You can’t perform that action at this time.
0 commit comments