Skip to content

TaskView is a self-hosted project and task management platform focused on clarity, ownership, and control. TaskView is built for teams that want a transparent, self-hosted alternative to SaaS task managers.

1.2 KB
Raw Blame
import { ALL_TASKS_LIST_ID } from '../../types/tasks.types';

// Reusable text/URL helpers shared across the messaging module.

// Frontend deep-link to a task: /:orgSlug/:projectId/:listId/:taskId. A task with no
// list lives in the virtual "All tasks" list (ALL_TASKS_LIST_ID sentinel, shared with web).
export function buildTaskDeepLink(orgSlug: string | null, goalId: number, taskId: number, goalListId: number | null): string | undefined {
    const appUrl = process.env.APP_URL;
    if (!appUrl || !orgSlug) return undefined;
    const listSegment = goalListId ?? ALL_TASKS_LIST_ID;
    return `${appUrl}/${orgSlug}/${goalId}/${listSegment}/${taskId}`;
}

// Only http(s) links are ever rendered — blocks tg://, javascript:, etc.
export function isSafeUrl(url: string): boolean {
    try {
        const scheme = new URL(url).protocol;
        return scheme === 'http:' || scheme === 'https:';
    } catch {
        return false;
    }
}

export { escapeHtml } from '../../utils/helpers';

// Slack mrkdwn requires escaping these three in text (incl. link labels).
export function escapeSlackText(text: string): string {
    return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
}