Skip to content
Open
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
2 changes: 1 addition & 1 deletion lib/bbcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 19 additions & 1 deletion tests/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>', function() {
bbcode.parse('[b]Bold[/b]', function(parse) {
Expand Down Expand Up @@ -99,6 +99,24 @@ describe('bcrypt', function() {
parse.should.equal('<a target="_blank" href="http://example.com">url</a>');
});
});

it('should parse [url]<url#hash>[/url] to <a href=<url#hash>>', function() {
bbcode.parse('[url]http://example.com/#hash[/url]', function(parse) {
parse.should.equal('<a target="_blank" href="http://example.com/#hash">http://example.com/#hash</a>');
});
});

it('should parse [url=<url#hash>] to <a href=<url#hash>>', function() {
bbcode.parse('[url=http://example.com/#hash]url[/url]', function(parse) {
parse.should.equal('<a target="_blank" href="http://example.com/#hash">url</a>');
});
});

it('should parse [url="<url#hash>"] to <a href=<url#hash>>', function() {
bbcode.parse('[url="http://example.com/#hash"]url[/url]', function(parse) {
parse.should.equal('<a target="_blank" href="http://example.com/#hash">url</a>');
});
});
});

describe('should parse [img]', function() {
Expand Down