Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make URL case insensitive. #1350

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/marked.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this is case-insensitive, could you also change a-zA-Z to a-z?

_backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
del: /^~+(?=\S)([\s\S]*?\S)~+/,
text: edit(inline.text)
Expand Down Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions test/unit/marked-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});