Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 41d5f84

Browse files
committed
Fix linkification
1 parent 30f95ae commit 41d5f84

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

shared/normalize-url.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// @flow
22

3-
const PROTOCOL = /(http(s?)):\/\//gi;
3+
const STARTS_WITH_PROTOCOL = /^https?:\/\//i;
44

5-
const addProtocolToString = (string: string) => {
6-
// if the string starts with http or https, we are good
7-
if (PROTOCOL.test(string)) {
8-
return string;
5+
// Note(@mxstbr): This method assumes that a string passed into it is already verified to be an URL
6+
// it'll just append https:// to anything that doesn't look like an URL
7+
const addProtocolToString = (url: string) => {
8+
if (STARTS_WITH_PROTOCOL.test(url)) {
9+
return url;
910
} else {
10-
// otherwise it doesn't start with a protocol, prepend http
11-
return `http://${string}`;
11+
return `https://${url}`;
1212
}
1313
};
1414

0 commit comments

Comments
 (0)