diff --git a/lib/bbcode.js b/lib/bbcode.js index 59b853e..9403607 100644 --- a/lib/bbcode.js +++ b/lib/bbcode.js @@ -62,7 +62,7 @@ exports.parse = function(post, cb) { var number_re = /^[\\.0-9]{1,8}$/i; // reserved, unreserved, escaped and alpha-numeric [RFC2396] - var uri_re = /^[-;\/\?:@&=\+\$,_\.!~\*'\(\)%0-9a-z]{1,512}$/i; + var uri_re = /^[-;#\/\?:@&=\+\$,_\.!~\*'\(\)%0-9a-z]{1,512}$/i; // main regular expression: CRLF, [tag=option], [tag="option"] [tag] or [/tag] var postfmt_re = /([\r\n])|(?:\[([a-z]{1,16})(?:=(?:"|'|)([^\x00-\x1F"'\(\)<>\[\]]{1,256}))?(?:"|'|)\])|(?:\[\/([a-z]{1,16})\])/ig; diff --git a/tests/parse.js b/tests/parse.js index fd4b00c..10af689 100644 --- a/tests/parse.js +++ b/tests/parse.js @@ -2,7 +2,7 @@ var bbcode = require('../lib/bbcode'); require('should'); -describe('bcrypt', function() { +describe('bbcode', function() { describe('#parse', function() { it('should parse [b] to ', function() { bbcode.parse('[b]Bold[/b]', function(parse) { @@ -99,6 +99,24 @@ describe('bcrypt', function() { parse.should.equal('url'); }); }); + + it('should parse [url][/url] to >', function() { + bbcode.parse('[url]http://example.com/#hash[/url]', function(parse) { + parse.should.equal('http://example.com/#hash'); + }); + }); + + it('should parse [url=] to >', function() { + bbcode.parse('[url=http://example.com/#hash]url[/url]', function(parse) { + parse.should.equal('url'); + }); + }); + + it('should parse [url=""] to >', function() { + bbcode.parse('[url="http://example.com/#hash"]url[/url]', function(parse) { + parse.should.equal('url'); + }); + }); }); describe('should parse [img]', function() {