Skip to content

Commit

Permalink
compiled to ES5
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcorvi committed Feb 26, 2017
1 parent 18c4f54 commit 28ce606
Show file tree
Hide file tree
Showing 11 changed files with 52 additions and 52 deletions.
20 changes: 10 additions & 10 deletions dist-browser/anchorme.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,17 @@ var hasprotocol = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
function default_1(str) {
str = str.toLowerCase();
if (str.startsWith("http://"))
if (str.indexOf("http://") === 0)
{ return "http://"; }
else if (str.startsWith("https://"))
else if (str.indexOf("https://") === 0)
{ return "https://"; }
else if (str.startsWith("ftp://"))
else if (str.indexOf("ftp://") === 0)
{ return "ftp://"; }
else if (str.startsWith("ftps://"))
else if (str.indexOf("ftps://") === 0)
{ return "ftps://"; }
else if (str.startsWith("file:///"))
else if (str.indexOf("file:///") === 0)
{ return "file:///"; }
else if (str.startsWith("mailto:"))
else if (str.indexOf("mailto:") === 0)
{ return "mailto:"; }
else
{ return false; }
Expand Down Expand Up @@ -395,18 +395,18 @@ function url2tag(fragment, options) {
}
if (options.attributes === undefined)
{ options.attributes = []; }
return ("<a href=\"" + href + "\" " + (options.attributes.map(function (attribute) {
return "<a href=\"" + href + "\" " + options.attributes.map(function (attribute) {
if (typeof attribute === 'function') {
var name = (attribute(fragment) || {}).name;
var value = (attribute(fragment) || {}).value;
if (name && !value)
{ return " name "; }
if (name && value)
{ return (" " + name + "=\"" + value + "\" "); }
{ return " " + name + "=\"" + value + "\" "; }
}
else
{ return (" " + (attribute.name) + "=\"" + (attribute.value) + "\" "); }
}).join("")) + ">" + original + "</a>");
{ return " " + attribute.name + "=\"" + attribute.value + "\" "; }
}).join("") + ">" + original + "</a>";
}
});

Expand Down
2 changes: 1 addition & 1 deletion dist-browser/anchorme.min.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions dist-node/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("./util");
const email_1 = require("./tests/email");
const ip_1 = require("./tests/ip");
const url_1 = require("./tests/url");
const transform_1 = require("./transform/transform");
const hasprotocol_1 = require("./tests/hasprotocol");
const anchorme = function (str, options) {
var util_1 = require("./util");
var email_1 = require("./tests/email");
var ip_1 = require("./tests/ip");
var url_1 = require("./tests/url");
var transform_1 = require("./transform/transform");
var hasprotocol_1 = require("./tests/hasprotocol");
var anchorme = function (str, options) {
options = util_1.defaultOptions(options);
var result = transform_1.default(str, options);
return result;
Expand Down
6 changes: 3 additions & 3 deletions dist-node/separate/fix.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function fixSeparators(arr, sep1, sep2) {
arr.forEach((bit, i) => {
arr.forEach(function (bit, i) {
if ((bit.indexOf(".") > -1) &&
(!(arr[i - 1] === sep1 && arr[i + 1] === sep2)) &&
(arr[i + 1] === sep1 || arr[i + 1] === sep2) // the one after it, is either sep1 or sep2
Expand All @@ -53,8 +53,8 @@ exports.fixSeparators = fixSeparators;
function default_1(arr) {
arr = fixSeparators(arr, "(", ")");
arr = fixSeparators(arr, "[", "]");
arr = fixSeparators(arr, `"`, `"`);
arr = fixSeparators(arr, `'`, `'`);
arr = fixSeparators(arr, "\"", "\"");
arr = fixSeparators(arr, "'", "'");
return arr;
}
exports.default = default_1;
2 changes: 1 addition & 1 deletion dist-node/separate/separate.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fix_1 = require("./fix");
var fix_1 = require("./fix");
/**
*
* Split the string with word separators
Expand Down
8 changes: 4 additions & 4 deletions dist-node/tests/email.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lists_1 = require("../lists");
var lists_1 = require("../lists");
// pattern that an emails MUST have
const pattern = /^[a-z0-9!#$%&'*+\-/=?^_`{|}~.]+@([a-z0-9%\-]+\.){1,}([a-z0-9\-]+)?$/i;
var pattern = /^[a-z0-9!#$%&'*+\-/=?^_`{|}~.]+@([a-z0-9%\-]+\.){1,}([a-z0-9\-]+)?$/i;
// patterns that an email can not have
const negativePatterns = [
var negativePatterns = [
/^[!#$%&'*+\-/=?^_`{|}~.]/,
/[.]{2,}[a-z0-9!#$%&'*+\-/=?^_`{|}~.]+@/i,
/\.@/
];
function default_1(str) {
// general pattern recognition
const match = str.match(pattern);
var match = str.match(pattern);
if (match === null)
return false;
// doesn't have a negative pattern
Expand Down
12 changes: 6 additions & 6 deletions dist-node/tests/hasprotocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
Object.defineProperty(exports, "__esModule", { value: true });
function default_1(str) {
str = str.toLowerCase();
if (str.startsWith("http://"))
if (str.indexOf("http://") === 0)
return "http://";
else if (str.startsWith("https://"))
else if (str.indexOf("https://") === 0)
return "https://";
else if (str.startsWith("ftp://"))
else if (str.indexOf("ftp://") === 0)
return "ftp://";
else if (str.startsWith("ftps://"))
else if (str.indexOf("ftps://") === 0)
return "ftps://";
else if (str.startsWith("file:///"))
else if (str.indexOf("file:///") === 0)
return "file:///";
else if (str.startsWith("mailto:"))
else if (str.indexOf("mailto:") === 0)
return "mailto:";
else
return false;
Expand Down
4 changes: 2 additions & 2 deletions dist-node/tests/ip.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("../util");
var util_1 = require("../util");
// general IP pattern https://regex101.com/r/rzUcJ4/1
const pattern = /^(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?(\/.*)?$/;
var pattern = /^(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?(\/.*)?$/;
function default_1(str) {
if (!pattern.test(str))
return false;
Expand Down
8 changes: 4 additions & 4 deletions dist-node/tests/url.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const util_1 = require("../util");
const lists_1 = require("../lists");
const pattern = /^(https?:\/\/|ftps?:\/\/)?([a-z0-9%\-]+\.){1,}([a-z0-9\-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:\/\?#\[\]@!$&'\(\)\*\+,;=%]+)?)?$/i;
var util_1 = require("../util");
var lists_1 = require("../lists");
var pattern = /^(https?:\/\/|ftps?:\/\/)?([a-z0-9%\-]+\.){1,}([a-z0-9\-]+)?(:(\d{1,5}))?(\/([a-z0-9\-._~:\/\?#\[\]@!$&'\(\)\*\+,;=%]+)?)?$/i;
function default_1(str) {
// general pattern recognition https://regex101.com/r/RgKTA4/2
const match = str.match(pattern);
var match = str.match(pattern);
if (match === null)
return false;
// validate TLD
Expand Down
12 changes: 6 additions & 6 deletions dist-node/transform/identify.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const lists_1 = require("../lists");
const hasprotocol_1 = require("../tests/hasprotocol");
const email_1 = require("../tests/email");
const ip_1 = require("../tests/ip");
const url_1 = require("../tests/url");
var lists_1 = require("../lists");
var hasprotocol_1 = require("../tests/hasprotocol");
var email_1 = require("../tests/email");
var ip_1 = require("../tests/ip");
var url_1 = require("../tests/url");
function default_1(inputArr, options) {
return inputArr.map((fragment, index) => {
return inputArr.map(function (fragment, index) {
var encoded = encodeURI(fragment);
// quick validations
// 1
Expand Down
16 changes: 8 additions & 8 deletions dist-node/transform/transform.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const separate_1 = require("../separate/separate");
const separate_2 = require("../separate/separate");
const identify_1 = require("./identify");
var separate_1 = require("../separate/separate");
var separate_2 = require("../separate/separate");
var identify_1 = require("./identify");
function default_1(str, options) {
var arr = separate_1.separate(str);
var identified = identify_1.default(arr, options);
Expand All @@ -17,7 +17,7 @@ function default_1(str, options) {
return listed;
}
// transform objects to HTML tags
identified = identified.map((fragment) => {
identified = identified.map(function (fragment) {
if (typeof fragment === "string")
return fragment;
return url2tag(fragment, options);
Expand All @@ -39,16 +39,16 @@ function url2tag(fragment, options) {
}
if (options.attributes === undefined)
options.attributes = [];
return `<a href="${href}" ${options.attributes.map((attribute) => {
return "<a href=\"" + href + "\" " + options.attributes.map(function (attribute) {
if (typeof attribute === 'function') {
var name = (attribute(fragment) || {}).name;
var value = (attribute(fragment) || {}).value;
if (name && !value)
return " name ";
if (name && value)
return ` ${name}="${value}" `;
return " " + name + "=\"" + value + "\" ";
}
else
return ` ${attribute.name}="${attribute.value}" `;
}).join("")}>${original}</a>`;
return " " + attribute.name + "=\"" + attribute.value + "\" ";
}).join("") + ">" + original + "</a>";
}

0 comments on commit 28ce606

Please sign in to comment.