From e797ca8e37ac69eadf0a4a42ab4c2e27544f9441 Mon Sep 17 00:00:00 2001 From: Daniel Walsh Date: Tue, 5 Mar 2024 13:52:43 +0000 Subject: [PATCH] Add :worker deeplink --- src/scripts/popup.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/scripts/popup.js b/src/scripts/popup.js index 0ecd86d..d5fe306 100644 --- a/src/scripts/popup.js +++ b/src/scripts/popup.js @@ -101,11 +101,25 @@ function parseUrlPath(url) { path.shift(); } + // if a workers path, get the worker name + let workerName = ''; + if (path[0] === 'workers') { + path.shift(); // /workers + path.shift(); // /services + path.shift(); // /view + workerName = path[0]; + path.shift(); + } + // no data detected, return the path rejoined - if (accountId === '' && zoneDomain === '' && pagesName === '' && pagesDeploymentId === '') { + if (accountId === '' && zoneDomain === '' && pagesName === '' && pagesDeploymentId === '' && workerName === '') { return `/${path.join('/')}`; } + if (accountId !== '' && workerName !== '') { + return `/:account/workers/services/view/:worker/${path.join('/')}`; + } + // if pagesName and pagesDeploymentId are both present, return the path for pages if (accountId !== '' && pagesName !== '' && pagesDeploymentId !== '') { return `/:account/pages/view/:pages-project/:pages-deployment/${path.join('/')}`;