mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-11 09:51:30 +00:00
fix: normalize collection pathnames in EnvironmentSecretsStore (#7283)
* fix: normalize collection pathnames in EnvironmentSecretsStore * fix * fix
This commit is contained in:
@@ -2,6 +2,8 @@ const _ = require('lodash');
|
||||
const Store = require('electron-store');
|
||||
const { encryptStringSafe } = require('../utils/encryption');
|
||||
|
||||
const posixifyPath = (p) => (p ? p.replace(/\\/g, '/') : p);
|
||||
|
||||
/**
|
||||
* Sample secrets store file
|
||||
*
|
||||
@@ -28,6 +30,7 @@ class EnvironmentSecretsStore {
|
||||
}
|
||||
|
||||
storeEnvSecrets(collectionPathname, environment) {
|
||||
const normalizedPathname = posixifyPath(collectionPathname);
|
||||
const envVars = [];
|
||||
_.each(environment.variables, (v) => {
|
||||
if (v.secret) {
|
||||
@@ -39,12 +42,12 @@ class EnvironmentSecretsStore {
|
||||
});
|
||||
|
||||
const collections = this.store.get('collections') || [];
|
||||
const collection = _.find(collections, (c) => c.path === collectionPathname);
|
||||
const collection = _.find(collections, (c) => posixifyPath(c.path) === normalizedPathname);
|
||||
|
||||
// if collection doesn't exist, create it, add the environment and save
|
||||
if (!collection) {
|
||||
collections.push({
|
||||
path: collectionPathname,
|
||||
path: normalizedPathname,
|
||||
environments: [
|
||||
{
|
||||
name: environment.name,
|
||||
@@ -57,6 +60,8 @@ class EnvironmentSecretsStore {
|
||||
return;
|
||||
}
|
||||
|
||||
collection.path = normalizedPathname;
|
||||
|
||||
// if collection exists, check if environment exists
|
||||
// if environment doesn't exist, add the environment and save
|
||||
collection.environments = collection.environments || [];
|
||||
@@ -77,8 +82,9 @@ class EnvironmentSecretsStore {
|
||||
}
|
||||
|
||||
getEnvSecrets(collectionPathname, environment) {
|
||||
const normalizedPathname = posixifyPath(collectionPathname);
|
||||
const collections = this.store.get('collections') || [];
|
||||
const collection = _.find(collections, (c) => c.path === collectionPathname);
|
||||
const collection = _.find(collections, (c) => posixifyPath(c.path) === normalizedPathname);
|
||||
if (!collection) {
|
||||
return [];
|
||||
}
|
||||
@@ -92,8 +98,9 @@ class EnvironmentSecretsStore {
|
||||
}
|
||||
|
||||
renameEnvironment(collectionPathname, oldName, newName) {
|
||||
const normalizedPathname = posixifyPath(collectionPathname);
|
||||
const collections = this.store.get('collections') || [];
|
||||
const collection = _.find(collections, (c) => c.path === collectionPathname);
|
||||
const collection = _.find(collections, (c) => posixifyPath(c.path) === normalizedPathname);
|
||||
if (!collection) {
|
||||
return;
|
||||
}
|
||||
@@ -108,8 +115,9 @@ class EnvironmentSecretsStore {
|
||||
}
|
||||
|
||||
deleteEnvironment(collectionPathname, environmentName) {
|
||||
const normalizedPathname = posixifyPath(collectionPathname);
|
||||
const collections = this.store.get('collections') || [];
|
||||
const collection = _.find(collections, (c) => c.path === collectionPathname);
|
||||
const collection = _.find(collections, (c) => posixifyPath(c.path) === normalizedPathname);
|
||||
if (!collection) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ const { generateUidBasedOnHash } = require('./common');
|
||||
const { withLock, getWorkspaceLockKey } = require('./workspace-lock');
|
||||
|
||||
// Normalize Windows backslash paths to forward slashes for cross-platform compatibility.
|
||||
const posixifyPath = (p) => p.replace(/\\/g, '/');
|
||||
const posixifyPath = (p) => (p ? p.replace(/\\/g, '/') : p);
|
||||
|
||||
const WORKSPACE_TYPE = 'workspace';
|
||||
const OPENCOLLECTION_VERSION = '1.0.0';
|
||||
|
||||
Reference in New Issue
Block a user