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 ac57896
Showing 1 changed file with 3 additions and 1 deletion.
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 ac57896

Please sign in to comment.