Skip to content

Commit

Permalink
chore: Fix typos
Browse files Browse the repository at this point in the history
  • Loading branch information
Its-treason committed Oct 19, 2023
1 parent b8bbe86 commit e687fec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
36 changes: 18 additions & 18 deletions packages/bruno-electron/src/ipc/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const {
createDirectory,
searchForBruFiles,
sanitizeDirectoryName,
sanitizeFilenme
sanitizeFilename
} = require('../utils/filesystem');
const { stringifyJson } = require('../utils/common');
const { openCollectionDialog } = require('../app/collections');
Expand Down Expand Up @@ -104,7 +104,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
// new request
ipcMain.handle('renderer:new-request', async (event, pathname, request) => {
try {
const sanitizedPathname = path.join(pathname, sanitizeFilenme(request.name) + '.bru');
const sanitizedPathname = path.join(pathname, sanitizeFilename(request.name) + '.bru');

if (fs.existsSync(sanitizedPathname)) {
throw new Error(`path: ${sanitizedPathname} already exists`);
Expand Down Expand Up @@ -141,8 +141,8 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
await createDirectory(envDirPath);
}

const filenameSanatized = sanitizeFilenme(`${name}.bru`);
const envFilePath = path.join(envDirPath, filenameSanatized);
const filenameSanitized = sanitizeFilename(`${name}.bru`);
const envFilePath = path.join(envDirPath, filenameSanitized);
if (fs.existsSync(envFilePath)) {
throw new Error(`environment: ${envFilePath} already exists`);
}
Expand Down Expand Up @@ -172,9 +172,9 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
await createDirectory(envDirPath);
}

let envFilePath = path.join(envDirPath, `${sanitizeFilenme(environment.name)}.bru`);
let envFilePath = path.join(envDirPath, `${sanitizeFilename(environment.name)}.bru`);
if (!fs.existsSync(envFilePath)) {
// Fallback to unsatized filename for old envs
// Fallback to unsanitized filename for old envs
envFilePath = path.join(envDirPath, `${environment.name}.bru`);
if (!fs.existsSync(envFilePath)) {
throw new Error(`environment: ${envFilePath} does not exist`);
Expand All @@ -196,16 +196,16 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
ipcMain.handle('renderer:rename-environment', async (event, collectionPathname, environmentName, newName) => {
try {
const envDirPath = path.join(collectionPathname, 'environments');
let envFilePath = path.join(envDirPath, `${sanitizeFilenme(environmentName)}.bru`);
let envFilePath = path.join(envDirPath, `${sanitizeFilename(environmentName)}.bru`);
if (!fs.existsSync(envFilePath)) {
// Fallback to unsatized env name
// Fallback to unsanitized env name
envFilePath = path.join(envDirPath, `${environmentName}.bru`);
if (!fs.existsSync(envFilePath)) {
throw new Error(`environment: ${envFilePath} does not exist`);
}
}

const newEnvFilePath = path.join(envDirPath, `${sanitizeFilenme(newName)}.bru`);
const newEnvFilePath = path.join(envDirPath, `${sanitizeFilename(newName)}.bru`);
if (fs.existsSync(newEnvFilePath) && envFilePath !== newEnvFilePath) {
throw new Error(`environment: ${newEnvFilePath} already exists`);
}
Expand All @@ -228,9 +228,9 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
ipcMain.handle('renderer:delete-environment', async (event, collectionPathname, environmentName) => {
try {
const envDirPath = path.join(collectionPathname, 'environments');
let envFilePath = path.join(envDirPath, `${sanitizeFilenme(environmentName)}.bru`);
let envFilePath = path.join(envDirPath, `${sanitizeFilename(environmentName)}.bru`);
if (!fs.existsSync(envFilePath)) {
// Fallback to unsatized env name
// Fallback to unsanitized env name
envFilePath = path.join(envDirPath, `${environmentName}.bru`);
if (!fs.existsSync(envFilePath)) {
throw new Error(`environment: ${envFilePath} does not exist`);
Expand Down Expand Up @@ -273,9 +273,9 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
throw new Error(`path: ${oldPathFull} is not a bru file`);
}

const newSantitizedPath = path.join(newPath, sanitizeFilenme(newName) + '.bru');
if (fs.existsSync(newSantitizedPath) && newSantitizedPath !== oldPathFull) {
throw new Error(`path: ${newSantitizedPath} already exists`);
const newSanitizedPath = path.join(newPath, sanitizeFilename(newName) + '.bru');
if (fs.existsSync(newSanitizedPath) && newSanitizedPath !== oldPathFull) {
throw new Error(`path: ${newSanitizedPath} already exists`);
}

// update name in file and save new copy, then delete old copy
Expand All @@ -284,13 +284,13 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection

jsonData.name = newName;

moveRequestUid(oldPathFull, newSantitizedPath);
moveRequestUid(oldPathFull, newSanitizedPath);

const content = jsonToBru(jsonData);
await writeFile(newSantitizedPath, content);
await writeFile(newSanitizedPath, content);

// Because of santization the name can change but the path stays the same
if (newSantitizedPath !== oldPathFull) {
// Because of sanitization the name can change but the path stays the same
if (newSanitizedPath !== oldPathFull) {
fs.unlinkSync(oldPathFull);
}
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions packages/bruno-electron/src/utils/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const sanitizeDirectoryName = (name) => {
return name.replace(/[<>:"/\\|?*\x00-\x1F]+/g, '-');
};

const sanitizeFilenme = (name) => {
const sanitizeFilename = (name) => {
return name.replace(/[<>:"/\\|?*\x00-\x1F]/g, '_');
};

Expand All @@ -137,5 +137,5 @@ module.exports = {
searchForFiles,
searchForBruFiles,
sanitizeDirectoryName,
sanitizeFilenme
sanitizeFilename
};

0 comments on commit e687fec

Please sign in to comment.