Housekeeping
This commit is contained in:
parent
d6aeef85d6
commit
6c4adb1127
7 changed files with 11 additions and 38 deletions
|
@ -401,12 +401,6 @@ const main = () => {
|
|||
setDownloadPath(mainWindow.webContents);
|
||||
allowExternalLinks(mainWindow.webContents);
|
||||
|
||||
// TODO(MR): Remove or resurrect
|
||||
// The commit that introduced this header override had the message
|
||||
// "fix cors issue for uploads". Not sure what that means, so disabling
|
||||
// it for now to see why exactly this is required.
|
||||
// addAllowOriginHeader(mainWindow);
|
||||
|
||||
// Start loading the renderer.
|
||||
mainWindow.loadURL(rendererURL);
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
import { BrowserWindow } from "electron";
|
||||
|
||||
export function addAllowOriginHeader(mainWindow: BrowserWindow) {
|
||||
mainWindow.webContents.session.webRequest.onHeadersReceived(
|
||||
(details, callback) => {
|
||||
details.responseHeaders = lowerCaseHeaders(details.responseHeaders);
|
||||
details.responseHeaders["access-control-allow-origin"] = ["*"];
|
||||
callback({
|
||||
responseHeaders: details.responseHeaders,
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function lowerCaseHeaders(responseHeaders: Record<string, string[]>) {
|
||||
const headers: Record<string, string[]> = {};
|
||||
for (const key of Object.keys(responseHeaders)) {
|
||||
headers[key.toLowerCase()] = responseHeaders[key];
|
||||
}
|
||||
return headers;
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import { shell } from "electron/common";
|
||||
import { app, dialog } from "electron/main";
|
||||
import path from "node:path";
|
||||
import { posixPath } from "../utils/path";
|
||||
import { posixPath } from "../utils/electron";
|
||||
|
||||
export const selectDirectory = async () => {
|
||||
const result = await dialog.showOpenDialog({
|
||||
|
|
|
@ -5,7 +5,7 @@ import path from "node:path";
|
|||
import { FolderWatch, type CollectionMapping } from "../../types/ipc";
|
||||
import log from "../log";
|
||||
import { watchStore } from "../stores/watch";
|
||||
import { posixPath } from "../utils/path";
|
||||
import { posixPath } from "../utils/electron";
|
||||
import { fsIsDir } from "./fs";
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
import shellescape from "any-shell-escape";
|
||||
import { app } from "electron/main";
|
||||
import { exec } from "node:child_process";
|
||||
import path from "node:path";
|
||||
import { promisify } from "node:util";
|
||||
import log from "../log";
|
||||
|
||||
/** `true` if the app is running in development mode. */
|
||||
export const isDev = !app.isPackaged;
|
||||
|
||||
/**
|
||||
* Convert a file system {@link filePath} that uses the local system specific
|
||||
* path separators into a path that uses POSIX file separators.
|
||||
*/
|
||||
export const posixPath = (filePath: string) =>
|
||||
filePath.split(path.sep).join(path.posix.sep);
|
||||
|
||||
/**
|
||||
* Run a shell command asynchronously.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* @file grab bag of utitity functions.
|
||||
* @file grab bag of utility functions.
|
||||
*
|
||||
* Many of these are verbatim copies of functions from web code since there
|
||||
* isn't currently a common package that both of them share.
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
import path from "node:path";
|
||||
|
||||
/**
|
||||
* Convert a file system {@link filePath} that uses the local system specific
|
||||
* path separators into a path that uses POSIX file separators.
|
||||
*/
|
||||
export const posixPath = (filePath: string) =>
|
||||
filePath.split(path.sep).join(path.posix.sep);
|
Loading…
Add table
Reference in a new issue