Skip to content

Commit b6e8c9d

Browse files
committed
fix: render submission link with protocol
1 parent a67c3a2 commit b6e8c9d

File tree

1 file changed

+6
-3
lines changed
  • src/projects/detail/components/timeline/LinkItem

1 file changed

+6
-3
lines changed

src/projects/detail/components/timeline/LinkItem/LinkItem.jsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class LinkItem extends React.Component {
8888
// fallback to no-type if type is not supported to avoid errors due to lack of styles
8989
const type = _.includes(supportedTypes, link.type) ? link.type : ''
9090

91+
// if URL doesn't have protocol, then add `https`
92+
const url = link.url.match(/^[a-zA-Z]{3,}:\/\/.+/) ? link.url : `https://${link.url}`
93+
9194
return (
9295
<div
9396
styleName={cn(
@@ -102,7 +105,7 @@ class LinkItem extends React.Component {
102105
<div styleName="label-layer">
103106
<div styleName="link-item-text-group">
104107
<a
105-
href={link.url}
108+
href={url}
106109
styleName={cn('title', type)}
107110
target="_blank"
108111
rel="noopener noreferrer"
@@ -112,7 +115,7 @@ class LinkItem extends React.Component {
112115

113116
<div styleName="link-wrapper">
114117
<a
115-
href={link.url}
118+
href={url}
116119
styleName="link"
117120
target="_blank"
118121
rel="noopener noreferrer"
@@ -132,7 +135,7 @@ class LinkItem extends React.Component {
132135

133136
{!!link.isDownloadable && !updateLink && !deleteLink && !onSelectChange && (
134137
<a
135-
href={link.url}
138+
href={url}
136139
styleName="button download"
137140
target="_blank"
138141
rel="noopener noreferrer"

0 commit comments

Comments
 (0)