mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
be2d06a7c2
* feat(annotate): render html files by default * fix(annotate): support raw html assets and sharing * fix(annotate): address html first review followups * fix(editor): avoid raw html sidebar init crash * fix(annotate): support portable html shares * fix(annotate): harden html share support * fix(share): clear attachments when loading shared payloads * fix(share): warn on remote share link failures * perf(annotate): lazy-build html share payloads * test(annotate): guard lazy html share generation * test(annotate): drop flaky html share server test
23 lines
601 B
TypeScript
23 lines
601 B
TypeScript
import { dirname } from "path";
|
|
|
|
export function applyAnnotateDocSessionParams(
|
|
requestUrl: string,
|
|
sourceFilePath: string,
|
|
convertHtml: boolean,
|
|
): { url: string; changed: boolean } {
|
|
const docUrl = new URL(requestUrl);
|
|
let changed = false;
|
|
|
|
if (!docUrl.searchParams.has("base") && !/^https?:\/\//i.test(sourceFilePath)) {
|
|
docUrl.searchParams.set("base", dirname(sourceFilePath));
|
|
changed = true;
|
|
}
|
|
|
|
if (convertHtml && !docUrl.searchParams.has("convert")) {
|
|
docUrl.searchParams.set("convert", "1");
|
|
changed = true;
|
|
}
|
|
|
|
return { url: docUrl.toString(), changed };
|
|
}
|