mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 04:17:42 +08:00
FIX: Protocol-less links that begin with a
shouldn't error
This commit is contained in:
parent
16383a1749
commit
b9177af1eb
@ -114,10 +114,12 @@ export function setup(helper) {
|
||||
|
||||
replaceBBCode('url', contents => {
|
||||
if (!Array.isArray(contents)) { return; }
|
||||
if (contents.length === 1 && contents[0][0] === 'a') {
|
||||
|
||||
const first = contents[0];
|
||||
if (contents.length === 1 && Array.isArray(first) && first[0] === 'a') {
|
||||
// single-line bbcode links shouldn't be oneboxed, so we mark this as a bbcode link.
|
||||
if (typeof contents[0][1] !== 'object') { contents[0].splice(1, 0, {}); }
|
||||
contents[0][1]['data-bbcode'] = true;
|
||||
if (typeof first[1] !== 'object') { first.splice(1, 0, {}); }
|
||||
first[1]['data-bbcode'] = true;
|
||||
}
|
||||
return ['concat'].concat(contents);
|
||||
});
|
||||
|
@ -551,6 +551,7 @@ test('basic bbcode', function() {
|
||||
|
||||
test('urls', function() {
|
||||
cookedPara("[url]not a url[/url]", "not a url", "supports [url] that isn't a url");
|
||||
cookedPara("[url]abc.com[/url]", "abc.com", "no error when a url has no protocol and begins with a");
|
||||
cookedPara("[url]http://bettercallsaul.com[/url]", "<a href=\"http://bettercallsaul.com\">http://bettercallsaul.com</a>", "supports [url] without parameter");
|
||||
cookedPara("[url=http://example.com]example[/url]", "<a href=\"http://example.com\">example</a>", "supports [url] with given href");
|
||||
cookedPara("[url=http://www.example.com][img]http://example.com/logo.png[/img][/url]",
|
||||
|
Loading…
x
Reference in New Issue
Block a user