Skip to content

Commit

Permalink
fix: sparql@... URLs (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
mightymax authored May 23, 2024
1 parent 8fa7e07 commit d34d1a0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/utils/getEndpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export default function getEndpoint(
return new File(endpoint);
} else if (endpoint !== undefined) {
try {
return new URL(endpoint);
// fix for GraphDB, see https://github.com/comunica/comunica/issues/962
return new URL((endpoint as string).replace(/^sparql@/, ''));
} catch (e) {
throw new Error(`"${endpoint as string}" is not a valid URL`);
}
Expand Down
25 changes: 25 additions & 0 deletions src/utils/tests/utilities.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,31 @@ describe('Utilities', () => {
// getEndpoint is use in Stage's Iterator, and it will throw there.
expect(() => new Stage(pipeline, stageConfig)).to.throw('Error in the iterator of stage `Stage 1`: "invalidExample" is not a valid URL')
})
it('should work with URL\'s prepended with \'sparql@\'', () => {
const url = 'sparql@https://www.goudatijdmachine.nl/sparql/repositories/nafotocollectie' // will be accepted
const config: LDWorkbenchConfiguration = {
name: 'Example Pipeline',
description: 'This is an example pipeline. It uses files that are available in this repository and SPARQL endpoints that should work.\n',
destination: 'file://pipelines/data/example-pipeline.nt',
stages: [
{
name: 'Stage 1',
iterator: {
query: 'file://static/example/iterator-stage-1.rq',
endpoint: url
},
generator: [
{
query: 'file://static/example/generator-stage-1-1.rq'
}
] }
]
}
const pipeline = new Pipeline(config, {silent: true})
const stageConfig = config.stages[0]
// getEndpoint is use in Stage's Iterator, and it will throw there.
expect(() => new Stage(pipeline, stageConfig)).to.not.throw()
})
it('should throw if stage has undefined endpoint and is first stage', () => {
const endpoint = undefined
const config: LDWorkbenchConfiguration = {
Expand Down

0 comments on commit d34d1a0

Please sign in to comment.