From e10f4264b18c05e41228a8eeba669a2432f4bb2c Mon Sep 17 00:00:00 2001 From: Dan Lee Date: Wed, 2 Oct 2024 01:34:21 -0700 Subject: [PATCH] fix(hyper-link): Move toString out of while loop to prevent memory leak (#687) --- extensions/hyper-link/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/hyper-link/src/index.ts b/extensions/hyper-link/src/index.ts index 130aaf81f..c2c4ddb81 100644 --- a/extensions/hyper-link/src/index.ts +++ b/extensions/hyper-link/src/index.ts @@ -41,10 +41,10 @@ class HyperLinkIcon extends WidgetType { function hyperLinkDecorations(view: EditorView, anchor?: HyperLinkExtensionOptions['anchor']) { const widgets: Array> = []; - const doc = view.state.doc; + const doc = view.state.doc.toString(); let match; - while ((match = defaultRegexp.exec(doc.toString())) !== null) { + while ((match = defaultRegexp.exec(doc)) !== null) { const from = match.index; const to = from + match[0].length; const widget = Decoration.widget({