Skip to content

Commit 064184d

Browse files
authored
Fix NCT reference link (#1096)
1 parent 308c937 commit 064184d

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/main/webapp/app/oncokb-frontend-commons/src/components/RefComponent.tsx

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Tooltip from 'rc-tooltip';
2-
import { getNCBIlink } from '../lib/urls';
2+
import { getNCBIlink, getNCTlink } from '../lib/urls';
33
import * as React from 'react';
44

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

5151
if (this.props.content.toLowerCase().includes('pmid')) {
5252
prefix = 'PMID: ';
53-
} else if (this.props.content.toLowerCase().includes('nct')) {
54-
prefix = 'NCT';
55-
}
56-
57-
if (prefix) {
5853
link = (
5954
<a
6055
target="_blank"
@@ -64,6 +59,20 @@ export default class RefComponent extends React.Component<{
6459
{`${prefix}${ids.join(', ')}`}
6560
</a>
6661
);
62+
} else if (this.props.content.toLowerCase().includes('nct')) {
63+
if (ids[0]) {
64+
prefix = 'NCT';
65+
const studyId = `${prefix}${ids[0]}`;
66+
link = (
67+
<a
68+
target="_blank"
69+
rel="noopener noreferrer"
70+
href={getNCTlink(`/study/${studyId}`)}
71+
>
72+
{studyId}
73+
</a>
74+
);
75+
}
6776
}
6877
}
6978

src/main/webapp/app/oncokb-frontend-commons/src/lib/urls.ts

+12
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,15 @@ export function getNCBIlink(
2323
...params,
2424
});
2525
}
26+
27+
export function getNCTlink(pathnameOrParams?: BuildUrlParams | string): string {
28+
const params =
29+
typeof pathnameOrParams === 'string'
30+
? { pathname: pathnameOrParams }
31+
: pathnameOrParams;
32+
return URL.format({
33+
protocol: 'https',
34+
host: 'www.clinicaltrials.gov',
35+
...params,
36+
});
37+
}

0 commit comments

Comments
 (0)