FIX: Widgets should support links to foreign hosts
This commit is contained in:
parent
4d48a1dd79
commit
e831203897
|
@ -90,6 +90,15 @@ const DiscourseURL = Ember.Object.extend({
|
|||
});
|
||||
},
|
||||
|
||||
routeToTag(a) {
|
||||
if (a && a.host !== document.location.host) {
|
||||
document.location = a.href;
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.routeTo(a.href);
|
||||
},
|
||||
|
||||
/**
|
||||
Our custom routeTo method is used to intelligently overwrite default routing
|
||||
behavior.
|
||||
|
|
|
@ -48,15 +48,9 @@ export default createWidget('home-logo', {
|
|||
|
||||
click(e) {
|
||||
if (wantsNewWindow(e)) { return false; }
|
||||
|
||||
e.preventDefault();
|
||||
const a = $(e.target).closest('a')[0];
|
||||
if (a && a.host !== document.location.host) {
|
||||
document.location = a.href;
|
||||
}
|
||||
|
||||
DiscourseURL.routeTo(this.href());
|
||||
DiscourseURL.routeToTag($(e.target).closest('a')[0]);
|
||||
return false;
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -81,6 +81,6 @@ export default createWidget('link', {
|
|||
this.sendWidgetEvent('linkClicked');
|
||||
}
|
||||
|
||||
return DiscourseURL.routeTo(this.href(this.attrs));
|
||||
return DiscourseURL.routeToTag($(e.target).closest('a')[0]);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue