From a2389d5c5b46d14797345ae75ba0bcc5b884f521 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Sun, 24 Sep 2017 10:59:38 -0700 Subject: [PATCH] Fix validation callback to use the uri, not whole row --- src/Linkifier.test.ts | 11 +++++++++++ src/Linkifier.ts | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Linkifier.test.ts b/src/Linkifier.test.ts index df9e459c..0878aafc 100644 --- a/src/Linkifier.test.ts +++ b/src/Linkifier.test.ts @@ -156,6 +156,17 @@ describe('Linkifier', () => { linkifier.linkifyRows(); }); + it('should validate the uri, not the row', done => { + addRow('abc test abc'); + linkifier.registerLinkMatcher(/test/, () => done(), { + validationCallback: (uri, cb) => { + assert.equal(uri, 'test'); + done(); + } + }); + linkifier.linkifyRows(); + }); + it('should disable link if false', done => { addRow('test'); linkifier.registerLinkMatcher(/test/, () => assert.fail(), { diff --git a/src/Linkifier.ts b/src/Linkifier.ts index fa47271c..42d20f9c 100644 --- a/src/Linkifier.ts +++ b/src/Linkifier.ts @@ -236,7 +236,7 @@ export class Linkifier extends EventEmitter implements ILinkifier { // Ensure the link is valid before registering if (matcher.validationCallback) { - matcher.validationCallback(text, isValid => { + matcher.validationCallback(uri, isValid => { // Discard link if the line has already changed if (this._rowsTimeoutId) { return;