Skip to content

Commit

Permalink
new build
Browse files Browse the repository at this point in the history
  • Loading branch information
alselawi committed May 8, 2020
1 parent ee804fe commit ec63993
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 35 deletions.
23 changes: 6 additions & 17 deletions dist/browser/anchorme.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@
exports.emailRegex = new RegExp("^(" + exports.email + ")$", "i");
exports.fileRegex = new RegExp("^(" + exports.file + ")$", "i");
exports.urlRegex = new RegExp("^(" + exports.url + ")$", "i");
exports.protocolPresent = /^((file:\/\/\/)|(https?:|ftps?:)\/\/|(mailto:))/i;
// identifying parts of the link
var iidxes = {
isURL: 0,
Expand Down Expand Up @@ -254,8 +253,7 @@
var regex_6 = regex.emailRegex;
var regex_7 = regex.fileRegex;
var regex_8 = regex.urlRegex;
var regex_9 = regex.protocolPresent;
var regex_10 = regex.iidxes;
var regex_9 = regex.iidxes;

var utils = createCommonjsModule(function (module, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
Expand All @@ -271,17 +269,9 @@
}
exports.checkParenthesis = checkParenthesis;
exports.maximumAttrLength = dictionary.htmlAttributes.sort(function (a, b) { return b.length - a.length; })[0].length;
function isInsideAttribute(quoteType, prevFragment) {
for (var index = 0; index < dictionary.htmlAttributes.length; index++) {
var atr = dictionary.htmlAttributes[index];
var targetString = atr.toLowerCase() + "=" + quoteType;
if (prevFragment.toLowerCase().indexOf(targetString) !== -1 &&
prevFragment.toLowerCase().indexOf(targetString) ===
prevFragment.length - targetString.length) {
return true;
}
}
return false;
function isInsideAttribute(prevFragment) {
return (/\s[a-z0-9-]+=('|")$/i.test(prevFragment) ||
/: ?url\(('|")?$/i.test(prevFragment));
}
exports.isInsideAttribute = isInsideAttribute;
function isInsideAnchorTag(target, fullInput, targetEnd) {
Expand Down Expand Up @@ -353,9 +343,8 @@
checking whether the token is already inside an HTML element by seeing if it's
preceded by an HTML attribute that would hold a url (e.g. scr, cite ...etc)
*/
if (input.charAt(start - 1) === "'" ||
input.charAt(start - 1) === '"') {
if (utils.isInsideAttribute(input.charAt(start - 1), input.substring(start - utils.maximumAttrLength - 5, start))) {
if (['""', "''", "()"].indexOf(input.charAt(start - 1) + input.charAt(end)) !== -1) {
if (utils.isInsideAttribute(input.substring(start - utils.maximumAttrLength - 15, start))) {
return "continue";
}
}
Expand Down
2 changes: 1 addition & 1 deletion dist/browser/anchorme.min.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions dist/node/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ var list = function (input) {
checking whether the token is already inside an HTML element by seeing if it's
preceded by an HTML attribute that would hold a url (e.g. scr, cite ...etc)
*/
if (input.charAt(start - 1) === "'" ||
input.charAt(start - 1) === '"') {
if (utils_1.isInsideAttribute(input.charAt(start - 1), input.substring(start - utils_1.maximumAttrLength - 5, start))) {
if (['""', "''", "()"].indexOf(input.charAt(start - 1) + input.charAt(end)) !== -1) {
if (utils_1.isInsideAttribute(input.substring(start - utils_1.maximumAttrLength - 15, start))) {
return "continue";
}
}
Expand Down
1 change: 0 additions & 1 deletion dist/node/regex.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export declare const ipRegex: RegExp;
export declare const emailRegex: RegExp;
export declare const fileRegex: RegExp;
export declare const urlRegex: RegExp;
export declare const protocolPresent: RegExp;
declare const iidxes: {
isURL: number;
isEmail: number;
Expand Down
1 change: 0 additions & 1 deletion dist/node/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ exports.ipRegex = new RegExp("^(" + ipv4 + "|" + ipv6 + ")$", "i");
exports.emailRegex = new RegExp("^(" + exports.email + ")$", "i");
exports.fileRegex = new RegExp("^(" + exports.file + ")$", "i");
exports.urlRegex = new RegExp("^(" + exports.url + ")$", "i");
exports.protocolPresent = /^((file:\/\/\/)|(https?:|ftps?:)\/\/|(mailto:))/i;
// identifying parts of the link
var iidxes = {
isURL: 0,
Expand Down
2 changes: 1 addition & 1 deletion dist/node/utils.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export declare function checkParenthesis(opening: string, closing: string, target: string, nextChar: string): boolean | undefined;
export declare const maximumAttrLength: number;
export declare function isInsideAttribute(quoteType: string, prevFragment: string): boolean;
export declare function isInsideAttribute(prevFragment: string): boolean;
export declare function isInsideAnchorTag(target: string, fullInput: string, targetEnd: number): boolean;
14 changes: 3 additions & 11 deletions dist/node/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,9 @@ function checkParenthesis(opening, closing, target, nextChar) {
}
exports.checkParenthesis = checkParenthesis;
exports.maximumAttrLength = dictionary_1.htmlAttributes.sort(function (a, b) { return b.length - a.length; })[0].length;
function isInsideAttribute(quoteType, prevFragment) {
for (var index = 0; index < dictionary_1.htmlAttributes.length; index++) {
var atr = dictionary_1.htmlAttributes[index];
var targetString = atr.toLowerCase() + "=" + quoteType;
if (prevFragment.toLowerCase().indexOf(targetString) !== -1 &&
prevFragment.toLowerCase().indexOf(targetString) ===
prevFragment.length - targetString.length) {
return true;
}
}
return false;
function isInsideAttribute(prevFragment) {
return (/\s[a-z0-9-]+=('|")$/i.test(prevFragment) ||
/: ?url\(('|")?$/i.test(prevFragment));
}
exports.isInsideAttribute = isInsideAttribute;
function isInsideAnchorTag(target, fullInput, targetEnd) {
Expand Down

0 comments on commit ec63993

Please sign in to comment.