mirror of
https://github.com/aljazceru/goose.git
synced 2026-02-23 07:24:24 +01:00
fix: fix desktop recipe url generation (#3209)
Co-authored-by: Alice Hau <ahau@squareup.com>
This commit is contained in:
@@ -21,7 +21,8 @@ interface RecipeEditorProps {
|
||||
// Function to generate a deep link from a recipe
|
||||
function generateDeepLink(recipe: Recipe): string {
|
||||
const configBase64 = Buffer.from(JSON.stringify(recipe)).toString('base64');
|
||||
return `goose://recipe?config=${configBase64}`;
|
||||
const urlSafe = encodeURIComponent(configBase64);
|
||||
return `goose://recipe?config=${urlSafe}`;
|
||||
}
|
||||
|
||||
export default function RecipeEditor({ config }: RecipeEditorProps) {
|
||||
|
||||
@@ -119,7 +119,7 @@ function parseDeepLink(deepLink: string): Recipe | null {
|
||||
return null;
|
||||
}
|
||||
|
||||
const configJson = Buffer.from(configParam, 'base64').toString('utf-8');
|
||||
const configJson = Buffer.from(decodeURIComponent(configParam), 'base64').toString('utf-8');
|
||||
return JSON.parse(configJson) as Recipe;
|
||||
} catch (error) {
|
||||
console.error('Failed to parse deep link:', error);
|
||||
|
||||
@@ -17,7 +17,8 @@ interface DeepLinkModalProps {
|
||||
// Function to generate a deep link from a bot config
|
||||
export function generateDeepLink(recipeConfig: RecipeConfig): string {
|
||||
const configBase64 = Buffer.from(JSON.stringify(recipeConfig)).toString('base64');
|
||||
return `goose://bot?config=${configBase64}`;
|
||||
const urlSafe = encodeURIComponent(configBase64);
|
||||
return `goose://bot?config=${urlSafe}`;
|
||||
}
|
||||
|
||||
export function DeepLinkModal({ recipeConfig: initialRecipeConfig, onClose }: DeepLinkModalProps) {
|
||||
|
||||
@@ -157,7 +157,9 @@ if (process.platform === 'win32') {
|
||||
const configParam = parsedUrl.searchParams.get('config');
|
||||
if (configParam) {
|
||||
try {
|
||||
recipeConfig = JSON.parse(Buffer.from(configParam, 'base64').toString('utf-8'));
|
||||
recipeConfig = JSON.parse(
|
||||
Buffer.from(decodeURIComponent(configParam), 'base64').toString('utf-8')
|
||||
);
|
||||
|
||||
// Check if this is a scheduled job
|
||||
const scheduledJobId = parsedUrl.searchParams.get('scheduledJob');
|
||||
@@ -260,7 +262,9 @@ function processProtocolUrl(parsedUrl: URL, window: BrowserWindow) {
|
||||
const configParam = parsedUrl.searchParams.get('config');
|
||||
if (configParam) {
|
||||
try {
|
||||
recipeConfig = JSON.parse(Buffer.from(configParam, 'base64').toString('utf-8'));
|
||||
recipeConfig = JSON.parse(
|
||||
Buffer.from(decodeURIComponent(configParam), 'base64').toString('utf-8')
|
||||
);
|
||||
|
||||
// Check if this is a scheduled job
|
||||
const scheduledJobId = parsedUrl.searchParams.get('scheduledJob');
|
||||
|
||||
Reference in New Issue
Block a user