mirror of
https://github.com/zulip/zulip-desktop.git
synced 2025-11-01 12:33:31 +00:00
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.
16 lines
428 B
JavaScript
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
|
|
};
|