Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const redirectToProtocol = (protocol, { appendSource, disable = false } = {}) => {
const currentProtocol = findCurrentProtocol();
if (protocol !== currentProtocol) {
if (disable === true) {
console.info(`forceProtocol: would have redirected from "${currentProtocol}" to "${protocol}"`);
} else {
const url = parse(window.location.href, true /* parse query string */);
url.protocol = protocol;
if (appendSource === true) {
url.query.source = currentProtocol;
}
window.location = format(url);
}
}
};
function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({
height: 676,
width: 440,
titleBarStyle: 'hidden',
hasShadow: true,
resizable: false,
fullscreen: false,
fullscreenable: false,
})
// and load the index.html of the app.
const startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '/../dist/index.html'),
protocol: 'file:',
slashes: true
});
mainWindow.loadURL(startUrl);
// Open the DevTools.
// mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
gjs.lib.acn.askDigest = function(pipe, func) {
// if(highestLatency <= 0) {
// func.apply(null, [true, 'not ready']);
// return;
// }
var inHash;
if(pipe.request.urlParseCacheStore)
inHash = url.format(pipe.request.urlParseCacheStore);
else
inHash = pipe.request.headers.host+url.format(pipe.request.urlParse);
var rnd = Math.random();
var msg = {
id: rnd,
inHash: inHash,
encoding: pipe.request.headers['accept-encoding']
};
requestTable[rnd] = msg;
gjs.lib.core.ipc.send('LFW', 'askDigest', msg);
requestTable[rnd].func = func;
requestTable[rnd].timeout = setTimeout(function() {
func.apply(null, [true, 'timeout']);
delete requestTable[rnd];
module.exports.normalizeUrl = function(u) {
return url.format(url.parse(u, true));
};
oauthUrl(redirect_uri: string, opts?: { state?: string, force?: boolean }) {
let query = {
response_type: 'code',
client_id: this.appKey,
redirect_uri,
force: opts && opts.force,
state: opts && opts.state
};
return format({ pathname: this.server + AUTHORIZE_URL, query });
}
internals.dispatch = async function (batchRequest, request) {
let path;
if (request.query) {
path = Url.format({
pathname: request.path,
query: request.query
});
}
else {
path = request.path;
}
const body = (request.payload !== null && request.payload !== undefined ? JSON.stringify(request.payload) : null);
const injectOptions = {
url: path,
method: request.method,
headers: batchRequest.headers,
payload: body
};
const gotConfig = (id, options, additional, config, fromEmbed, callback) => {
if (!config) {
return callback(Error('Could not find player config'));
}
try {
config = JSON.parse(config + (fromEmbed ? '}' : ''));
} catch (err) {
return callback(Error('Error parsing config: ' + err.message));
}
const url = urllib.format({
protocol: 'https',
host: INFO_HOST,
pathname: INFO_PATH,
query: {
video_id: id,
eurl: VIDEO_EURL + id,
ps: 'default',
gl: 'US',
hl: (options.lang || 'en'),
sts: config.sts,
},
});
request(url, options.requestOptions, (err, res, body) => {
if (err) return callback(err);
let info = querystring.parse(body);
function createloaderWin(siteUrl, isLocal) {
loaderWindow = new electron_1.BrowserWindow({
height: electron_1.screen.getPrimaryDisplay().size.height,
width: electron_1.screen.getPrimaryDisplay().size.width,
webPreferences: {
nodeIntegration: true,
offscreen: true
},
show: false
});
if (isLocal) {
loaderWindow.webContents.loadURL(url.format({
pathname: siteUrl,
protocol: 'file:',
slashes: true
})).then(function () {
loaderWindow.webContents.executeJavaScript('require("electron").ipcRenderer.send("html-ready", document.body.innerHTML);')
.catch(function (err) {
senderID.send('yes-view-err', err);
});
});
}
if (!isLocal) {
loaderWindow.webContents.loadURL(siteUrl, null).then(function () {
loaderWindow.webContents.executeJavaScript('require("electron").ipcRenderer.send("html-ready", document.body.innerHTML);');
}).catch(function (err) {
senderID.send('yes-view-err', err);
});
export const getUrl = (slug?: string): string => {
if (serve) {
return `http://localhost:4200/#/${slug || ''}`;
} else {
return format({
pathname: `${__dirname}/../dist/index.html`,
protocol: 'file',
slashes: true,
hash: slug || '/'
});
}
};
async function connect(parsedUrl) {
const dbUrl = url.format({ ...parsedUrl, pathname: "" });
const dbName = parsedUrl.pathname.slice(1);
const client = await MongoClient.connect(
dbUrl,
{ useNewUrlParser: true }
);
return client.db(dbName);
}