Skip to content

Commit

Permalink
Skohub: Fix issue in _loadScheme (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Jun 22, 2022
1 parent c006b96 commit cafc09e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/providers/skohub-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,20 @@ export default class SkohubProvider extends BaseProvider {
}

async _loadScheme({ scheme, ...config }) {
const uris = jskos.getAllUris(scheme)
let uris = jskos.getAllUris(scheme)
for (let uri of uris) {
if (this._schemeCache[uri]) {
return this._schemeCache[uri]
}
}
// Find main URI from this.schemes
const { uri } = this.schemes.find(s => jskos.compare(s, scheme)) || {}
const schemeFromList = this.schemes.find(s => jskos.compare(s, scheme))

if (!uri) {
if (!schemeFromList || !schemeFromList.uri) {
throw new errors.InvalidRequestError({ message: `Tried to load unsupported scheme (${scheme && scheme.uri})` })
}
const uri = schemeFromList.uri
uris = _.uniq(uris.concat(jskos.getAllUris(schemeFromList)))

let postfix = ".json"
if (uri.endsWith("/")) {
Expand All @@ -93,6 +95,7 @@ export default class SkohubProvider extends BaseProvider {

const { title, preferredNamespaceUri, hasTopConcept, description } = data

scheme = { uri, identifier: uris.filter(u => u !== uri) }
scheme.prefLabel = title
Object.keys(scheme.prefLabel || {}).forEach(key => {
scheme.prefLabel[key] = decodeUnicode(scheme.prefLabel[key])
Expand Down

0 comments on commit cafc09e

Please sign in to comment.