-
-
Notifications
You must be signed in to change notification settings - Fork 201
Help with conversion of Asana links? #235
-
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!
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 5 comments 2 replies
-
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,
});
},
},
Beta Was this translation helpful? Give feedback.
All reactions
-
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',
};
},
},
]
}
Beta Was this translation helpful? Give feedback.
All reactions
-
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" }); } }] }
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you @maciejb !
I used your example and modified it a little bit because I had some issues.
- 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. - I appended
?open_in_browser=trueto the pathname, otherwise the app would show me the "Opening link in asana - click here to continue in browser" message
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',
};
},
}]
}
Beta Was this translation helpful? Give feedback.
All reactions
-
@pire I was having the same issues lately and couldn't figure it out. Thanks for sharing! :)
Beta Was this translation helpful? Give feedback.
All reactions
-
🎉 1
-
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', }, ] }
Beta Was this translation helpful? Give feedback.
All reactions
-
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"
},
Beta Was this translation helpful? Give feedback.