Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Help with conversion of Asana links? #235

SirHomeALotToo started this conversation in General
Discussion options

Hey folks, any idea how I can alter Asana URLs so they trigger the right pages in the Asana desktop app?
e.g. if you click on a link like: https://app.asana.com/0/1116731155503379/1201546786800222/f
it opens a browser where it gets converted to: https://app.asana.com/-/desktop_app_link?path=%2F0%2F1116731155503379%2F1201546786800222%2Ff%3F
I'm sure this is an easy regex match + URL encode, but it's beyond my skill level :-(
Thanks in advance!

You must be logged in to vote

Replies: 5 comments 2 replies

Comment options

The rewrite part is fairly straightforward, though attempts to route Asana links directly to the desktop app don't load the content of the link. This will open in the default browser, which then can pop open the Asana desktop app.

Ideally we can discern the URL format the app needs to jump straight to content and use that in Finicky rather than this intermediate URL + browser step.

{
 match: finicky.matchDomains(['app.asana.com']),
 url: ({ url }) => {
 const originalPath = encodeURIComponent(url.pathname);
 const rewritePath = `/-/desktop_app_link?path=${originalPath}`;
 return ({
 ...url,
 pathname: rewritePath,
 });
 },
 },
You must be logged in to vote
1 reply
Comment options

Thanks! Tried entering that but Finicky barfed when I saved:
2022年02月16日 09:27:09 - Configuration: Error: Expected "module.exports.handlers[0].browser" to be function(options), {
"name": "string",
"appType": "appPath, appName or bundleId",
"openInBackground": "boolean",
"profile": "string",
"args": "array"
}, string or null or array

Here's the full config file for reference:
module.exports = {
defaultBrowser: "Google Chrome",
handlers: [
{
match: finicky.matchDomains(['app.asana.com']),
url: ({ url }) => {
const originalPath = encodeURIComponent(url.pathname);
const rewritePath = '/-/desktop_app_link?path=${originalPath}';
return ({
...url,
pathname: rewritePath,
});
},
},
{
match: [
"https://.zoom.us", // match zoom urls

 ],
 browser: "/Applications/zoom.us.app"
},
{
 match: finicky.matchHostnames(['teams.microsoft.com']),
 browser: 'com.microsoft.teams',
 url({ url }) {
 return {
 ...url,
 protocol: 'msteams',
 };
 },
},

]
}

Comment options

I had success with Asana by rewriting the protocol and host components of the URL as follows:

module.exports = {
 defaultBrowser: "Safari",
 handlers: [{
 match: "https://app.asana.com/*",
 browser: "com.electron.asana",
 url: ({url}) => {
 return ({
 ...url,
 protocol: "asanadesktop",
 host: "/app"
 });
 }
 }]
}
You must be logged in to vote
0 replies
Comment options

Thank you @maciejb !

I used your example and modified it a little bit because I had some issues.

  1. I changed the match url to https://app.asana.com/0/* because attachments would not download. At least for me, they need to open in the default browser.
  2. I appended ?open_in_browser=true to the pathname, otherwise the app would show me the "Opening link in asana - click here to continue in browser" message

image

So! In case it helps anyone final code is:

module.exports = {
 defaultBrowser: "Safari",
 handlers: [{
 match: 'https://app.asana.com/0/*',
 browser: 'Asana',
 url: ({ url }) => {
 return {
 ...url,
 pathname: url.pathname + '?open_in_browser=true',
 protocol: 'asanadesktop',
 host: '/app',
 };
 },
 }]
}
You must be logged in to vote
1 reply
Comment options

@pire I was having the same issues lately and couldn't figure it out. Thanks for sharing! :)

Comment options

In Finicky v4 URL rewriting happens in the rewrite section, not in handlers. HTH anyone opening Asana links with the current version.

export default {
 defaultBrowser: "Google Chrome",
 
 rewrite: [
 {
 // Handle Slack's Asana redirect URLs (app.asana.com/app/asana/-/log?...)
 match: /app\.asana\.com\/app\/asana\/-\/log/,
 url: (url) => {
 const urlString = url.href;
 const taskMatch = urlString.match(/task%2F(\d+)/);
 if (taskMatch) {
 return new URL(`asanadesktop:///app/0/0/${taskMatch[1]}`);
 }
 return url;
 },
 },
 {
 // Direct Asana links (/0/... or /1/...)
 match: /app\.asana\.com\/[01]\//,
 url: (url) => {
 const urlString = url.href;
 const matches = urlString.match(/\/(\d{10,})/g);
 if (matches) {
 const taskId = matches[matches.length - 1].replace('/', '');
 return new URL(`asanadesktop:///app/0/0/${taskId}`);
 }
 return url;
 },
 },
 ],
 
 handlers: [
 {
 match: /^asanadesktop:/,
 browser: 'Asana',
 },
 ]
}
You must be logged in to vote
0 replies
Comment options

This is my solution which works for me so far as well:

 rewrite: [
 {
 match: (url) => url.host === "app.asana.com" && url.pathname.includes("log_view"),
 url: (url) => {
 const dest = url.searchParams.get("dest");
 if (!dest) return url.href; 
 try {
 const destUrl = new URL(dest);
 return `asanadesktop:///app${destUrl.pathname}${destUrl.search}`;
 } catch (e) {
 return url.href;
 }
 }
 },
 {
 match: (url) => url.host === "app.asana.com" && !url.pathname.includes("log_view"),
 url: (url) => `asanadesktop:///app${url.pathname}${url.search}`
 },
 ],
 handlers: [
 {
 // Asana App
 match: (url) => url.protocol === "asanadesktop:",
 browser: "Asana"
 },
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

AltStyle によって変換されたページ (->オリジナル) /