Skip to content

Commit

Permalink
fix: https imports
Browse files Browse the repository at this point in the history
  • Loading branch information
tpluscode committed Dec 18, 2023
1 parent 9996328 commit 3888a4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/twelve-seahorses-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"rdf-transform-graph-imports": patch
---

Fix error when resolving HTTPS imports
4 changes: 3 additions & 1 deletion lib/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ interface Options {
extension?: string
}

const PROTOCOL_PATTERN = /^https?:/i

export function resolveImport(importNode: Term, { extension }: Options = {}) {
if (importNode.termType !== 'NamedNode') {
throw new Error(`Import target must be a NamedNode. Got ${importNode.termType}`)
}

try {
const targetUri = new URL(importNode.value)
if (targetUri.protocol === 'http:') {
if (PROTOCOL_PATTERN.test(targetUri.protocol)) {
return targetUri
}

Expand Down

0 comments on commit 3888a4c

Please sign in to comment.