FIX: composer should only feature links to external sites

This commit is contained in:
Neil Lalonde
2017-02-08 15:34:42 -05:00
parent 5a4c393231
commit e077b3f141
3 changed files with 24 additions and 0 deletions

View File

@ -40,3 +40,15 @@ test("no onebox result", () => {
equal(find('.title-input input').val(), "http://www.example.com/nope-onebox.html", "title is unchanged");
});
});
test("ignore internal links", () => {
visit("/");
click('#create-topic');
const title = "http://" + window.location.hostname + "/internal-page.html";
fillIn('#reply-title', title);
andThen(() => {
equal(find('.d-editor-preview').html().trim().indexOf('onebox'), -1, "onebox preview doesn't show");
equal(find('.d-editor-input').val().length, 0, "link isn't put into the post");
equal(find('.title-input input').val(), title, "title is unchanged");
});
});

View File

@ -343,6 +343,14 @@ export default function() {
];
}
if (request.queryParams.url.indexOf('/internal-page.html') > -1) {
return [
200,
{"Content-Type": "application/html"},
'<aside class="onebox"><article class="onebox-body"><h3><a href="/internal-page.html">Internal Page 4 U</a></h3></article></aside>'
];
}
return [404, {"Content-Type": "application/html"}, ''];;
});
});