Skip to content

Commit

Permalink
Fix NCT reference link (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinlu3 authored Mar 20, 2024
1 parent 308c937 commit 064184d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Tooltip from 'rc-tooltip';
import { getNCBIlink } from '../lib/urls';
import { getNCBIlink, getNCTlink } from '../lib/urls';
import * as React from 'react';

import { ReferenceList } from './ReferenceList';
Expand Down Expand Up @@ -50,11 +50,6 @@ export default class RefComponent extends React.Component<{

if (this.props.content.toLowerCase().includes('pmid')) {
prefix = 'PMID: ';
} else if (this.props.content.toLowerCase().includes('nct')) {
prefix = 'NCT';
}

if (prefix) {
link = (
<a
target="_blank"
Expand All @@ -64,6 +59,20 @@ export default class RefComponent extends React.Component<{
{`${prefix}${ids.join(', ')}`}
</a>
);
} else if (this.props.content.toLowerCase().includes('nct')) {
if (ids[0]) {
prefix = 'NCT';
const studyId = `${prefix}${ids[0]}`;
link = (
<a
target="_blank"
rel="noopener noreferrer"
href={getNCTlink(`/study/${studyId}`)}
>
{studyId}
</a>
);
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions src/main/webapp/app/oncokb-frontend-commons/src/lib/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,15 @@ export function getNCBIlink(
...params,
});
}

export function getNCTlink(pathnameOrParams?: BuildUrlParams | string): string {
const params =
typeof pathnameOrParams === 'string'
? { pathname: pathnameOrParams }
: pathnameOrParams;
return URL.format({
protocol: 'https',
host: 'www.clinicaltrials.gov',
...params,
});
}

0 comments on commit 064184d

Please sign in to comment.