Skip to content

Commit

Permalink
added 'manual' content negotiation
Browse files Browse the repository at this point in the history
this way also vocabulary served via GitHub Pages can be used in editor
  • Loading branch information
sroertgen committed Oct 22, 2020
1 parent ca8de84 commit 8fb3847
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions frontend/src/components/JSONPointerForm/SkohubLookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,24 @@ const SkohubLookup = (props) => {
})

useEffect(() => {
fetch(schemaLocation, {
headers: {
Accept: 'application/json'
}
}).then(response => response.json())
fetch(
schemaLocation.endsWith('index.json') ? schemaLocation
: schemaLocation.endsWith('/') ? schemaLocation.concat('index.json')
: schemaLocation.concat('/index.json'), {
headers: {
Accept: 'application/json'
}
}).then(response => response.json())
.then(setScheme)

fetch(schemaLocation.includes('index.json') ? schemaLocation.replace(/.json?/, '.index') : schemaLocation, {
headers: {
Accept: 'text/index'
}
}).then(response => response.json())
fetch(
schemaLocation.endsWith('index.json') ? schemaLocation.replace(/.json?/, '.index')
: schemaLocation.endsWith('/') ? schemaLocation.concat('index.index')
: schemaLocation.concat('index.index'), {
headers: {
Accept: 'text/index'
}
}).then(response => response.json())
.then(serialized => {
const idx = FlexSearch.create()
idx.import(serialized)
Expand Down

0 comments on commit 8fb3847

Please sign in to comment.