mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 23:19:40 +01:00
core: fix Cannot read properties of undefined (reading 'startsWith') error on export
This commit is contained in:
committed by
Abdullah Atta
parent
62d677f9ad
commit
1e6f6ab477
@@ -184,7 +184,7 @@ export class Tiptap {
|
||||
this.data = new HTMLRewriter({
|
||||
ontag: (name, attr) => {
|
||||
const href = attr[ATTRIBUTES.href];
|
||||
if (name === "a" && href.startsWith("nn://")) {
|
||||
if (name === "a" && href && href.startsWith("nn://")) {
|
||||
const link = resolve(href);
|
||||
if (!link) return;
|
||||
attr[ATTRIBUTES.href] = link;
|
||||
@@ -244,7 +244,10 @@ export class Tiptap {
|
||||
if (types.includes("internalLinks")) {
|
||||
result.internalLinks.push(
|
||||
...findAll(
|
||||
(e) => e.tagName === "a" && e.attribs.href.startsWith("nn://"),
|
||||
(e) =>
|
||||
e.tagName === "a" &&
|
||||
!!e.attribs.href &&
|
||||
e.attribs.href.startsWith("nn://"),
|
||||
document.childNodes
|
||||
)
|
||||
.map((e) => parseInternalLink(e.attribs.href))
|
||||
|
||||
@@ -66,7 +66,7 @@ export function parseInternalLink(link: string): InternalLink | undefined {
|
||||
}
|
||||
|
||||
export function isInternalLink(link: string) {
|
||||
return link.startsWith("nn://");
|
||||
return link && link.startsWith("nn://");
|
||||
}
|
||||
|
||||
function isValidInternalType(type: string): type is InternalLinkType {
|
||||
|
||||
Reference in New Issue
Block a user