mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 18:10:06 -05:00
Route internal card links within the current WeKan page and wait for the destination card subscription before treating it as unavailable. Cover same-tab navigation in Chromium and link classification in Node tests. Thanks to carl-unique and xet7 ! Fixes #6711,
17 lines
501 B
JavaScript
17 lines
501 B
JavaScript
'use strict';
|
|
|
|
// Markdown card links use the same tab so FlowRouter can open the card popup.
|
|
function internalCardPath(href, currentUrl) {
|
|
try {
|
|
const link = new URL(href, currentUrl);
|
|
const current = new URL(currentUrl);
|
|
if (link.origin !== current.origin) return null;
|
|
if (!/\/b\/[^/]+\/[^/]+\/[^/]+\/?$/.test(link.pathname)) return null;
|
|
return `${link.pathname}${link.search}${link.hash}`;
|
|
} catch (_error) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
module.exports = { internalCardPath };
|