diff --git a/lib/marked.js b/lib/marked.js index 51c7c2ac06..8046be6fb7 100644 --- a/lib/marked.js +++ b/lib/marked.js @@ -606,7 +606,7 @@ inline.pedantic = merge({}, inline.normal, { inline.gfm = merge({}, inline.normal, { escape: edit(inline.escape).replace('])', '~|])').getRegex(), _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/, - url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, + url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/i, _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/, del: /^~+(?=\S)([\s\S]*?\S)~+/, text: edit(inline.text) @@ -647,6 +647,7 @@ function InlineLexer(links, options) { } else if (this.options.gfm) { if (this.options.breaks) { this.rules = inline.breaks; + this.rules.url = new RegExp(this.rules.url.source, 'i'); } else { this.rules = inline.gfm; } diff --git a/test/unit/marked-spec.js b/test/unit/marked-spec.js index 97789afe09..cdb897488c 100644 --- a/test/unit/marked-spec.js +++ b/test/unit/marked-spec.js @@ -25,3 +25,13 @@ describe('Test paragraph token type', function () { expect(tokens[7].type).toBe('text'); }); }); + +describe('Test url token type', function () { + it('should use the "url" type', function () { + const md = 'HtTps://www.testsite.com'; + + const tokens = marked.lexer(md); + + expect(tokens[0].type).toBe('url'); + }); +});