Skip to content

Commit cafc09e

Browse files
committed
Skohub: Fix issue in _loadScheme (#29)
1 parent c006b96 commit cafc09e

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/providers/skohub-provider.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,18 +67,20 @@ export default class SkohubProvider extends BaseProvider {
6767
}
6868

6969
async _loadScheme({ scheme, ...config }) {
70-
const uris = jskos.getAllUris(scheme)
70+
let uris = jskos.getAllUris(scheme)
7171
for (let uri of uris) {
7272
if (this._schemeCache[uri]) {
7373
return this._schemeCache[uri]
7474
}
7575
}
7676
// Find main URI from this.schemes
77-
const { uri } = this.schemes.find(s => jskos.compare(s, scheme)) || {}
77+
const schemeFromList = this.schemes.find(s => jskos.compare(s, scheme))
7878

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

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

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

98+
scheme = { uri, identifier: uris.filter(u => u !== uri) }
9699
scheme.prefLabel = title
97100
Object.keys(scheme.prefLabel || {}).forEach(key => {
98101
scheme.prefLabel[key] = decodeUnicode(scheme.prefLabel[key])

0 commit comments

Comments
 (0)