Skip to content

Commit

Permalink
fix(html_tag): ignore case in regex
Browse files Browse the repository at this point in the history
  • Loading branch information
curbengh committed Sep 20, 2019
1 parent db04431 commit 9e3af48
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/encode_url.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { parse, format } = require('url');
const regexNonUrl = /^(data|javascript|mailto|vbscript)/gi;
const regexNonUrl = /^(data|javascript|mailto|vbscript)/i;

function encodeURL(str) {
const parsed = parse(str);
Expand Down
4 changes: 2 additions & 2 deletions lib/html_tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const encodeURL = require('./encode_url');
const escapeHTML = require('./escape_html');
const regexUrl = /(cite|download|href|src|url)$/;
const regexUrl = /(cite|download|href|src|url)$/i;

function encSrcset(str) {
str.split(' ')
Expand All @@ -24,7 +24,7 @@ function htmlTag(tag, attrs, text, escape = true) {
if (attrs[i] === null || typeof attrs[i] === 'undefined') result += '';
else {
if (i.match(regexUrl)) result += ` ${escapeHTML(i)}="${encodeURL(attrs[i])}"`;
else if (i.endsWith('srcset')) result += ` ${escapeHTML(i)}="${encSrcset(attrs[i])}"`;
else if (i.match(/srcset$/i)) result += ` ${escapeHTML(i)}="${encSrcset(attrs[i])}"`;
else result += ` ${escapeHTML(i)}="${escapeHTML(String(attrs[i]))}"`;
}
}
Expand Down

0 comments on commit 9e3af48

Please sign in to comment.