I’m trying to solve a problem I have at work. We have multiple subdomains and I frequently need to test one URL on multiple subdomains. E.g. dev.example.com
and local.example.com
. I want an action that when I select a URL offers me just the right choices for the selected URL. I also want a 4th action that extracts part of the URL for me. So I tried the following:
# popclip
name: example.com URL
requirements: [urls]
regex: (https?:\/\/\w+\.example\.com.*)
icon: circle filled E
actions:
- title: E Local
regex: (https?:\/\/\w+(?<!local)\.example\.com.*)
javascript: |
let urls = popclip.input.data.urls;
urls = urls.map(url => url.replace(/https?:\/\/\w+(?<!local)\.example\.com/, 'http://local.example.com'));
popclip.pasteText(url.join("\n"), { restore: false })
- title: E Dev
regex: (https?:\/\/\w+(?<!dev)\.example\.com.*)
javascript: |
let urls = popclip.input.data.urls;
urls = urls.map(url => url.replace(/https?:\/\/\w+(?<!local)\.example\.com/, 'https://dev.example.com'));
popclip.pasteText(url.join("\n"), { restore: false })
- title: E Sandbox
regex: (https?:\/\/\w+(?<!sandbox)\.example\.com.*)
javascript: |
let urls = popclip.input.data.urls;
urls = urls.map(url => url.replace(/https?:\/\/\w+(?<!local)\.example\.com/, 'https://sandbox.example.com'));
popclip.pasteText(url.join("\n"), { restore: false })
- title: workflow_id
regex: (https?:\/\/\w+(?<!sandbox)\.example\.com.*)
javascript: |
let urls = popclip.input.data.urls;
urls = urls.map(url => url.match(/\/(\d+\w+)\/?/)[0]);
popclip.pasteText(url.join("\n"), { restore: false })
I suspect, that in lieu of multiple actions, I need options. I can easily move the 4th action to its own one, but I only want the relevant options for the domains to appear if possible.
Any suggestions or hints are greatly received!