-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathurl.js
More file actions
31 lines (31 loc) · 1.07 KB
/
url.js
File metadata and controls
31 lines (31 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
"use strict";
// @ts-nocheck
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleCustomProtocol = handleCustomProtocol;
const electron_1 = require("electron");
const handle_1 = __importDefault(require("./handle"));
const debounce = (func, wait) => {
let timeout;
return function (...args) {
clearTimeout(timeout);
timeout = setTimeout(() => func.apply(this, args), wait);
};
};
async function handleCustomProtocol(window) {
const mode = process.env.NODE_ENV;
const debouncedHandleUrl = debounce((requestUrl, window) => {
if (process.platform === 'darwin') {
electron_1.app.dock.hide();
}
handleUrl(requestUrl, window);
}, 500);
}
function handleUrl(url, window) {
const urlObj = new URL(url);
const route = urlObj.hostname;
const params = Object.fromEntries(urlObj.searchParams);
window.webContents.send("protocol-data", { route, params });
}