Skip to content

Commit c6c7085

Browse files
committed
fix: domain normalization when no protocol and port are provided
1 parent 67bebb8 commit c6c7085

3 files changed

Lines changed: 9 additions & 8 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"vue-jest": "latest"
7272
},
7373
"optionalDependencies": {
74-
"ipx": "^0.9.7"
74+
"ipx": "^0.9.9"
7575
},
7676
"engines": {
7777
"node": ">=14.16.0"

src/module.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ const imageModule: Module<ModuleOptions> = async function imageModule (moduleOpt
3939
const options: ModuleOptions = defu(moduleOptions, nuxt.options.image, defaults)
4040

4141
// Normalize domains to hostname
42-
options.domains = options.domains
43-
.map(domain => new URL(domain, 'https://').hostname)
44-
.filter(Boolean) as string[]
42+
options.domains = options.domains.map((d) => {
43+
if (!d.startsWith('http')) { d = 'http://' + d }
44+
return new URL(d).hostname
45+
}).filter(Boolean) as string[]
4546

4647
// Normalize alias to start with leading slash
4748
options.alias = Object.fromEntries(Object.entries(options.alias).map(e => [withLeadingSlash(e[0]), e[1]]))

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6919,10 +6919,10 @@ ip@^1.1.5:
69196919
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48"
69206920
integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==
69216921

6922-
ipx@^0.9.7:
6923-
version "0.9.7"
6924-
resolved "https://registry.yarnpkg.com/ipx/-/ipx-0.9.7.tgz#5b425af86c7a367a2bf82b0a5087d073a9ab32ab"
6925-
integrity sha512-qnSJuzWrmJAg0mTfo5xy6YXA63VAWvzT7ZSXWW4ZWlN4T3+k3zU6ygn1YtBw0Qo1n5abdJak1tH/0Mgb9urFWA==
6922+
ipx@^0.9.9:
6923+
version "0.9.9"
6924+
resolved "https://registry.yarnpkg.com/ipx/-/ipx-0.9.9.tgz#baa5a69b38234b08854ef8ae5264e8d8d5f8e267"
6925+
integrity sha512-H+VZZoh/2TmInXR074NvcOvwAKXKpwRvxk2sxZW0XAvBvMBOTY9z2Tv+XkooxU1q6VgNbnZIg8E6ZnO5+FKlQA==
69266926
dependencies:
69276927
consola "^2.15.3"
69286928
defu "^6.0.0"

0 commit comments

Comments
 (0)