Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: normalize options.domains with host and port #680

Merged
merged 1 commit into from
Jan 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix(module): parse options.domains with parseURL #659
roald-di committed Dec 9, 2022
commit d066efdb1dcbd1af8456d8adbc7350cd4a1255bc
4 changes: 2 additions & 2 deletions src/module.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { withLeadingSlash } from 'ufo'
import { parseURL, withLeadingSlash } from 'ufo'
import { defineNuxtModule, addTemplate, addImports, createResolver, addComponent, addPlugin } from '@nuxt/kit'
import { resolveProviders, detectProvider } from './provider'
import type { ImageProviders, ImageOptions, InputProvider, CreateImageOptions } from './types'
@@ -54,7 +54,7 @@ export default defineNuxtModule<ModuleOptions>({
// Normalize domains to hostname
options.domains = options.domains.map((d) => {
if (!d.startsWith('http')) { d = 'http://' + d }
return new URL(d).hostname
return parseURL(d).host
}).filter(Boolean) as string[]

// Normalize alias to start with leading slash