FIX: don't create featured link if title includes more than a url
This commit is contained in:
parent
fb08441802
commit
23ea4b6739
|
@ -128,7 +128,7 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
@computed('composer.title', 'composer.titleLength')
|
@computed('composer.title', 'composer.titleLength')
|
||||||
isAbsoluteUrl(title, titleLength) {
|
isAbsoluteUrl(title, titleLength) {
|
||||||
return titleLength > 0 && /^(https?:)?\/\/[\w\.\-]+/i.test(title);
|
return titleLength > 0 && /^(https?:)?\/\/[\w\.\-]+/i.test(title) && !/\s/.test(title);
|
||||||
},
|
},
|
||||||
|
|
||||||
bodyIsDefault() {
|
bodyIsDefault() {
|
||||||
|
|
|
@ -63,4 +63,15 @@ QUnit.test("link is longer than max title length", assert => {
|
||||||
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
|
assert.ok(exists('.d-editor-textarea-wrapper .popup-tip.good'), 'the body is now good');
|
||||||
assert.equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article");
|
assert.equal(find('.title-input input').val(), "An interesting article", "title is from the oneboxed article");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test("onebox with title but extra words in title field", assert => {
|
||||||
|
visit("/");
|
||||||
|
click('#create-topic');
|
||||||
|
fillIn('#reply-title', "http://www.example.com/has-title.html test");
|
||||||
|
andThen(() => {
|
||||||
|
assert.equal(find('.d-editor-preview').html().trim().indexOf('onebox'), -1, "onebox preview doesn't show");
|
||||||
|
assert.equal(find('.d-editor-input').val().length, 0, "link isn't put into the post");
|
||||||
|
assert.equal(find('.title-input input').val(), "http://www.example.com/has-title.html test", "title is unchanged");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
Loading…
Reference in New Issue