Skip to content

Commit

Permalink
fix: bug where trailing forward slash would get missed by the URL red…
Browse files Browse the repository at this point in the history
…action
  • Loading branch information
JaredBett committed Aug 3, 2017
1 parent 6168a62 commit f684d51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/patterns.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ module.exports = {
salutation: /(^|\n(\s+)?)(dear|hi|hey|hello|greetings) ([^,:;\s]+(,? )?){1,5}[,;\n]/gi,
valediction: /([Tt]hank(s| you)( for [^!,.]+| again)?|[Cc]heers|[Ss]incerely|[Rr]egards|[Rr]espectfully|[Bb]est|[Bb]est regards|[Yy]ours truly)\s*[!,.]?\s*([A-Z&]([\w&]+)?\.?( )?)+[^a-z]*$/g,
digits: /\d+/g,
url: /([^\s:/?#]+):\/\/([^/?#\s]*)([^?#\s]*)(\?([^#\s]*))?(#([^\s]*))?\b/
url: /([^\s:/?#]+):\/\/([^/?#\s]*)([^?#\s]*)(\?([^#\s]*))?(#([^\s]*))?/
};
4 changes: 3 additions & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ defineTest('index.js', function (Redactor) {

it('should replace URLs', function () {
redactor.redact('My homepage is http://example.com').should.equal('My homepage is URL');
redactor.redact('ip http://127.0.01/example.html test').should.equal('ip URL test');
redactor.redact('ip http://127.0.0.1/example.html test').should.equal('ip URL test');
redactor.redact('custom protocol myapp://example.com').should.equal('custom protocol URL');
redactor.redact('Reset password url is https://example.com/reset/password/12345').should.equal('Reset password url is URL');
redactor.redact('complex http://user@pass:example.com:8080/reset/password/12345?foo=bar&hi=there#/app works?').should.equal('complex URL works?');
Expand All @@ -179,6 +179,8 @@ defineTest('index.js', function (Redactor) {
redactor.redact('before http://www.example.com/foo/bar after').should.equal('before URL after');
redactor.redact('before http://www.example.com/foo/bar?foo=bar after').should.equal('before URL after');
redactor.redact('before http://www.example.com/foo/bar?foo=bar#/foo/bar after').should.equal('before URL after');
redactor.redact('before http://www.example.com/sub/dir/ after').should.equal('before URL after');
redactor.redact('My homepage is http://example.com\nAnd that is that.').should.equal('My homepage is URL\nAnd that is that.');
});

});

0 comments on commit f684d51

Please sign in to comment.