1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var tslib_1 = require("tslib");
|
4 | var linkify_it_1 = tslib_1.__importDefault(require("linkify-it"));
|
5 | var whitelistedURLPatterns = [
|
6 | /^https?:\/\
|
7 | /^ftps?:\/\
|
8 | /^\
|
9 | /^mailto:/im,
|
10 | /^skype:/im,
|
11 | /^callto:/im,
|
12 | /^facetime:/im,
|
13 | /^git:/im,
|
14 | /^irc6?:/im,
|
15 | /^news:/im,
|
16 | /^nntp:/im,
|
17 | /^feed:/im,
|
18 | /^cvs:/im,
|
19 | /^svn:/im,
|
20 | /^mvn:/im,
|
21 | /^ssh:/im,
|
22 | /^scp:\/\
|
23 | /^sftp:\/\
|
24 | /^itms:/im,
|
25 | /^notes:/im,
|
26 | /^hipchat:\/\
|
27 | /^sourcetree:/im,
|
28 | /^urn:/im,
|
29 | /^tel:/im,
|
30 | /^xmpp:/im,
|
31 | /^telnet:/im,
|
32 | /^vnc:/im,
|
33 | /^rdp:/im,
|
34 | /^whatsapp:/im,
|
35 | /^slack:/im,
|
36 | /^sips?:/im,
|
37 | /^magnet:/im,
|
38 | ];
|
39 | exports.isSafeUrl = function (url) {
|
40 | return whitelistedURLPatterns.some(function (p) { return p.test(url.trim()) === true; });
|
41 | };
|
42 | var linkify = linkify_it_1.default();
|
43 | linkify.add('sourcetree:', 'http:');
|
44 | function getLinkMatch(str) {
|
45 | var match = str && linkify.match(str);
|
46 | return match && match[0];
|
47 | }
|
48 | exports.getLinkMatch = getLinkMatch;
|
49 |
|
50 |
|
51 |
|
52 | function normalizeUrl(url) {
|
53 | var match = getLinkMatch(url);
|
54 | return (match && match.url) || url;
|
55 | }
|
56 | exports.normalizeUrl = normalizeUrl;
|
57 |
|
\ | No newline at end of file |