Files
zulip-desktop/app/renderer/js/utils/link-util.js
2017-06-18 09:58:13 +08:00

30 lines
559 B
JavaScript

'use strict';
const wurl = require('wurl');
let instance = null;
class LinkUtil {
constructor() {
if (instance) {
return instance;
} else {
instance = this;
}
return instance;
}
isInternal(currentUrl, newUrl) {
const currentDomain = wurl('hostname', currentUrl);
const newDomain = wurl('hostname', newUrl);
const skipImages = '.jpg|.gif|.png|.jpeg|.JPG|.PNG';
// We'll be needing this to open images in default browser
return (currentDomain === newDomain) && !newUrl.match(skipImages);
}
}
module.exports = new LinkUtil();