Opening Slack Jira Cloud links in the right browser
I use OpenIn to open links in a given browser when I click on them in other applications. This is really helpful to keep various work related stuff in different browsers or profiles and I find it very helpful.
One thing that’s bothered me is that links from the Jira Cloud Slack App ignore my OpenIn rules and always open in Safari and I finally sat down to work out why.
The investigation
I create a new OpenIn rule and enabled multiple browsers so that OpenIn would present a choice window to me.
It looks like this

At the bottom, we can see the link that OpenIn has received.
Even though the presented URL in the Slack app is https://my-client.atlassian.net/browser/PROJ-123, and if you right click and copy link, that’s what you get in your clipboard, when you click on the link, you get a slack.com link.
Copying that link, it’s of the form: https://slack.com/openid/connect/login_initiate_redirect?login_hint=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.blah.blah.
That’s interesting! I’ve seen that eyJhbGci prefix often enough to know on sight that it’s the start of base64 encoded JWT and sure enough, base64 decoding it proved that it was.
The format of JWT is {header}.{payload}.{signature} and it’s unencrypted, so we can inspect the payload easily enough. This is redacted, but it’s of the form:
{ "aud" : "123456789.123456789", "auth_time" : 1758615553, "exp" : 1758619153, "https://slack.com/target_uri" : "https://{my-client}.atlassian.net/browse/PROJ-123", "https://slack.com/team_id" : "ABCDEFGHI", "https://slack.com/user_id" : "U01AB2CDEF3", "iat" : 1758615553, "iss" : "https://slack.com", "sub" : "rob@{my-client}.com" }
We can see that the URL that we want to go to is in the payload’s "https://slack.com/target_uri" property, so we just need to set up OpenIn to use that URL and pick the appropriate browser.
OpenIn’s custom scripts
One really nice feature of OpenIn is that you can write custom scripts for a rule, so we can use this to extract the payload and pick the browser.
So I read the web page and wrote some Javascript!
The work we need to do is:
- Extract the payload from the query parameter
- JSON decode it
- Read the target_uri
- Choose browser based on target_uri
This needs a few helper functions
Helper functions
Extracting the payload is straightforward JS. We need the text between the two .s:
function extractJwtPayload(str) {
const parts = str.split('.');
return parts.length >= 3 ? parts[1] : '';
}
As OpenIn uses WebKit’s JavaScriptCore, we can decode base64 using Uint8Array.fromBase64():
function base64Decode(str) {
const uint8Array = Uint8Array.fromBase64(str);
return String.fromCharCode(...uint8Array);
}
We also need to select the browser that we want the link to open in. This is done in OpenIn by setting all the “visible” browsers to false, except the one you want:
function selectBrowser(browser) {
let apps = ctx.getApps()
apps.forEach(function (app) {
app.visible = (app.name == browser)
})
}
Do the work
Having set everything up, we can now find the target_uri and choose the browser.
Firstly we only want to do this work if the source app is Slack and that we have a login_hint parameter:
if (ctx.getSourceApp().path.startsWith("/Applications/Slack.app")
&& ctx.url.searchParams.has('login_hint')) {
Extracting the target_uri is a case of using the functions we’ve written:
const login_hint = ctx.url.searchParams.get('login_hint');
const jwtPayload = extractJwtPayload(login_hint);
const payload = base64Decode(jwtPayload).replace(/\0/g, '');
const data = JSON.parse(payload);
const target_uri = data['https://slack.com/target_uri'];
Note that I discovered some null bytes during testing, so removed them from the decoded string.
Now we set OpenIn’s URI and select the browser we want:
// Set OpenIn's URL ctx.url.href=target_uri; // Select the browser if (target_uri.includes("my-client-1")) { selectBrowser("Firefox"); return; } if (target_uri.includes("my-client-2")) { selectBrowser("Firefox"); return; } // Default to Safari selectBrowser("Safari"); return;
and we’re done.
That’s it
That’s it! Whenever I click on a Jira link in Slack, the correct browser opens directly to where I want to go.
The full script is here: openin-slack-app-link.js