Skip to content

Commit

Permalink
Add supportsExtension to STAC entities
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Jan 26, 2025
1 parent ae5cafa commit bbe6238
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/stac.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,22 @@ class STAC extends STACHypermedia {
return false;
}

/**
* Checks whether a specific extension is implemented.
*
* The pattern can contain `*` as a wildcard, e.g. for version numbers.
*
* @param {*} pattern
* @returns
*/
supportsExtension(pattern) {
if (!Array.isArray(this.stac_extensions)) {
return false;
}
let regexp = new RegExp('^' + pattern.replaceAll('*', '[^/]+') + '$');
return Boolean(this.stac_extensions.find(uri => regexp.test(uri)));
}

}

export default STAC;

0 comments on commit bbe6238

Please sign in to comment.