Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bbcode

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bbcode - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

16

lib/bbcode.js

@@ -27,2 +27,3 @@ // -----------------------------------------------------------------------

// [url=http://blogs.stonesteps.ca/showpost.asp?pid=33][b]BBCode[/b] Parser[/url]
// [url="http://blogs.stonesteps.ca/showpost.asp?pid=33"][b]BBCode[/b] Parser[/url]
//

@@ -54,3 +55,3 @@ // [q=http://blogs.stonesteps.ca/showpost.asp?pid=33]inline quote[/q]

// aceptable BBcode tags, optionally prefixed with a slash
var tagname_re = /^\/?(?:b|i|u|pre|samp|code|colou?r|size|noparse|url|s|q|blockquote|img|u?list|li)$/;
var tagname_re = /^\/?(?:b|i|u|pre|samp|code|colou?r|size|noparse|url|link|s|q|blockquote|img|u?list|li)$/;

@@ -66,4 +67,4 @@ // color names or hex color

// main regular expression: CRLF, [tag=option], [tag] or [/tag]
var postfmt_re = /([\r\n])|(?:\[([a-z]{1,16})(?:=([^\x00-\x1F"'\(\)<>\[\]]{1,256}))?\])|(?:\[\/([a-z]{1,16})\])/ig;
// 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;

@@ -120,3 +121,3 @@ // stack frame object

// ignore any tags if there's an open option-less [url] tag
if(opentags.length && opentags[opentags.length-1].bbtag == "url" && urlstart >= 0)
if(opentags.length && (opentags[opentags.length-1].bbtag == "url" || opentags[opentags.length-1].bbtag == "link") && urlstart >= 0)
return "[" + m2 + "]";

@@ -156,2 +157,3 @@

case "link":
case "url":

@@ -222,3 +224,3 @@ opentags.push(new taginfo_t(m2, "</a>"));

if(m4 == "url") {
if(m4 == "url" || m4 == "link") {
// if there was no option, use the content of the [url] tag

@@ -271,3 +273,3 @@ if(urlstart > 0)

// if there's an open [url] at the top, close it
if(opentags[opentags.length-1].bbtag == "url") {
if(opentags[opentags.length-1].bbtag == "url" || opentags[opentags.length-1].bbtag == "link") {
opentags.pop();

@@ -288,2 +290,2 @@ endtags += "\">" + post.substr(urlstart, post.length-urlstart) + "</a>";

}
}
}

@@ -5,3 +5,3 @@ {

"main": "./lib/bbcode",
"version": "0.1.1",
"version": "0.1.2",
"author": "Nick Campbell (http://github.com/ncb000gt)",

@@ -8,0 +8,0 @@ "repository": {

@@ -60,6 +60,38 @@ var bbcode = require('../lib/bbcode');

it('should parse [url=<url>] to <a href=<url>>', function() {
bbcode.parse('[url=http://example.com]url[/url]', function(parse) {
parse.should.equal('<a href="http://example.com">url</a>');
describe('should parse [url] and [link]', function() {
it('should parse [url=<url>] to <a href=<url>>', function() {
bbcode.parse('[url=http://example.com]url[/url]', function(parse) {
parse.should.equal('<a href="http://example.com">url</a>');
});
});
it('should parse [url="<url>"] to <a href=<url>>', function() {
bbcode.parse('[url="http://example.com"]url[/url]', function(parse) {
parse.should.equal('<a href="http://example.com">url</a>');
});
});
it('should parse [url=\'<url>\'] to <a href=<url>>', function() {
bbcode.parse('[url=\'http://example.com\']url[/url]', function(parse) {
parse.should.equal('<a href="http://example.com">url</a>');
});
});
it('should parse [link=<url>]test[/link]', function() {
bbcode.parse('[link=http://example.com]url[/link]', function(parse) {
parse.should.equal('<a href="http://example.com">url</a>');
});
});
it('should parse [link="<url>"]test[/link]', function() {
bbcode.parse('[link="http://example.com"]url[/link]', function(parse) {
parse.should.equal('<a href="http://example.com">url</a>');
});
});
it('should parse [link=\'<url>\']test[/link]', function() {
bbcode.parse('[link=\'http://example.com\']url[/link]', function(parse) {
parse.should.equal('<a href="http://example.com">url</a>');
});
});
});

@@ -74,2 +106,14 @@

it('as attribute with quotes - [img="<img>"] to <img src=<img>>', function() {
bbcode.parse('[img="http://example.com/img.png"][/img]', function(parse) {
parse.should.equal('<img src="http://example.com/img.png" />');
});
});
it('as attribute with single quotes - [img=\'<img>\'] to <img src=<img>>', function() {
bbcode.parse('[img=\'http://example.com/img.png\'][/img]', function(parse) {
parse.should.equal('<img src="http://example.com/img.png" />');
});
});
it('as content - [img]<img>[/img] to <img src=<img>>', function() {

@@ -145,3 +189,8 @@ bbcode.parse('[img]http://example.com/img.png[/img]', function(parse) {

});
it('should parse and return rather than callback', function() {
var parse = bbcode.parse('[b][i][u]Hai[/u][/i][/b]');
parse.should.equal('<b><i><u>Hai</u></i></b>');
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc