Files
zulip-desktop/app/main/link-helper.js
James Steele 39f3df5b8f Restrict internal links to the same host only
A zulip service is hosted with a particular hostname and not across a
whole domain. Internal links should respect this otherwise links to other
distinct services hosted under the same domain will be loaded by the app
and not in a separate browser window.
2016-09-10 21:32:32 +01:00

16 lines
428 B
JavaScript

const wurl = require('wurl');
// Check link if it's internal/external
function linkIsInternal(currentUrl, newUrl) {
const currentDomain = wurl('hostname', currentUrl);
const newDomain = wurl('hostname', newUrl);
return currentDomain === newDomain;
}
// We'll be needing this to open images in default browser
const skipImages = '.jpg|.gif|.png|.jpeg|.JPG|.PNG';
exports = module.exports = {
linkIsInternal, skipImages
};