A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
clipper: convert relative urls to absolute
Ammar Ahmedf6a4af8c0022
diff --git a/packages/clipper/src/clone.ts b/packages/clipper/src/clone.tsindex 9ed9489cd..e90d81e6a 100644--- a/packages/clipper/src/clone.ts+++ b/packages/clipper/src/clone.ts@@ -215,12 +215,25 @@ function processClone(copyStyle(original, clone, options);clonePseudoElements(original, clone, options);}-+ fixRelativeUrl(clone);copyUserInput(original, clone);fixSvg(clone);return clone;}+function fixRelativeUrl(node: HTMLElement) {+ const attributes = ["href", "src"];+ const baseUrl = window.location.href;+ for (const attribute of attributes) {+ const url = node.getAttribute(attribute);+ const relativeUrl = url?.startsWith("http") ? undefined : url;+ if (relativeUrl) {+ const absoluteUrl = new URL(relativeUrl, baseUrl).href;+ node.setAttribute(attribute, absoluteUrl);+ }+ }+}+function copyFont(source: CSSStyleDeclaration, target: CSSStyleDeclaration) {target.font = source.font;target.fontFamily = source.fontFamily;