Skip to content

Commit

Permalink
Merge pull request #2 from WalshyDev/walshy/add-worker-deeplink
Browse files Browse the repository at this point in the history
Add :worker deeplink
  • Loading branch information
mackenly authored Mar 5, 2024
2 parents b999baf + e797ca8 commit 8d9426b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/scripts/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('/')}`;
Expand Down

0 comments on commit 8d9426b

Please sign in to comment.