From c5d6c2c9d98989378fbd9e16d0705bbf08e020f9 Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Tue, 3 Oct 2023 13:45:05 +0200 Subject: [PATCH] fix: ambiguity logic --- src/claim.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/claim.js b/src/claim.js index b900f4e..b2d34ee 100644 --- a/src/claim.js +++ b/src/claim.js @@ -313,12 +313,13 @@ export class Claim { * @returns {boolean} */ isAmbiguous () { - if (this._status === ClaimStatus.INIT) { + if (this._status < ClaimStatus.MATCHED) { throw new Error('The claim has not been matched yet') } if (this._matches.length === 0) { throw new Error('The claim has no matches') } + if (this._status >= 200 && this._status < 300) return false return this._matches.length > 1 || this._matches[0].claim.uriIsAmbiguous } @@ -334,7 +335,7 @@ export class Claim { let displayServiceProviderName = null let displayServiceProviderId = null - if (!this.isAmbiguous() || (this._status >= 200 && this._status < 300)) { + if (this._status >= ClaimStatus.MATCHED && this._matches.length > 0 && !this.isAmbiguous()) { displayName = this._matches[0].profile.display displayUrl = this._matches[0].profile.uri displayServiceProviderName = this._matches[0].about.name