Merge pull request #1005 from Tyriar/fix_validation_callback
Fix validation callback to use the uri, not whole row
This commit is contained in:
@@ -156,6 +156,17 @@ describe('Linkifier', () => {
|
|||||||
linkifier.linkifyRows();
|
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 => {
|
it('should disable link if false', done => {
|
||||||
addRow('test');
|
addRow('test');
|
||||||
linkifier.registerLinkMatcher(/test/, () => assert.fail(), {
|
linkifier.registerLinkMatcher(/test/, () => assert.fail(), {
|
||||||
|
|||||||
+1
-1
@@ -236,7 +236,7 @@ export class Linkifier extends EventEmitter implements ILinkifier {
|
|||||||
|
|
||||||
// Ensure the link is valid before registering
|
// Ensure the link is valid before registering
|
||||||
if (matcher.validationCallback) {
|
if (matcher.validationCallback) {
|
||||||
matcher.validationCallback(text, isValid => {
|
matcher.validationCallback(uri, isValid => {
|
||||||
// Discard link if the line has already changed
|
// Discard link if the line has already changed
|
||||||
if (this._rowsTimeoutId) {
|
if (this._rowsTimeoutId) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user