aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMelissa Zhang <mzhang19096@gmail.com>2020-07-25 15:52:35 -0700
committerMelissa Zhang <mzhang19096@gmail.com>2020-07-25 15:52:35 -0700
commit48ae073706a501f4312a3e56f5e94e16a1183474 (patch)
tree8f2e5bd1ff737a4d569c84d236a804cc64926c90
parentb1308d059c78e516c6062e4dd6f92dd409cf17a7 (diff)
fix link deletion
-rw-r--r--src/client/apis/hypothesis/HypothesisApiUtils.ts9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/client/apis/hypothesis/HypothesisApiUtils.ts b/src/client/apis/hypothesis/HypothesisApiUtils.ts
index cf265479a..1158dcc11 100644
--- a/src/client/apis/hypothesis/HypothesisApiUtils.ts
+++ b/src/client/apis/hypothesis/HypothesisApiUtils.ts
@@ -69,14 +69,11 @@ export namespace Hypothesis {
await editAnnotation(annotationId, newText);
};
- /**
- * Edit an annotation with ID @param annotationId to delete a hyperlink to the Dash document with URL @param linkUrl
- */
export const deleteLink = async (annotationId: string, linkUrl: string) => {
const annotation = await fetchAnnotation(annotationId);
- const regex = new RegExp(`(\[[^[]*)\(${linkUrl.replace('/', '\/')}\)`);
- const target = regex.exec(annotation.text); // use regex to extract the link to be deleted, which is written in [title](hyperlink) format
- target && editAnnotation(annotationId, annotation.text.replace(target[0], ''));
+ const regex = new RegExp(`\\[[^\\]]*\\]\\(${linkUrl}\\)`); // finds the link (written in [title](hyperlink) format) to be deleted
+ const out = annotation.text.replace(regex, "");
+ editAnnotation(annotationId, out);
};
// Finds the most recent placeholder annotation created and returns its ID