Files
wekan/models/lib/internalCardLink.js
T
Lauri Ojansivu 0741a78475 Open linked card URLs in the current tab
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,
2026-09-22 15:12:52 +03:00

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 };