Skip to content

Commit

Permalink
fix: domain normalization when no protocol and port are provided
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Jun 22, 2022
1 parent 67bebb8 commit c6c7085
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"vue-jest": "latest"
},
"optionalDependencies": {
"ipx": "^0.9.7"
"ipx": "^0.9.9"
},
"engines": {
"node": ">=14.16.0"
Expand Down
7 changes: 4 additions & 3 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ const imageModule: Module<ModuleOptions> = async function imageModule (moduleOpt
const options: ModuleOptions = defu(moduleOptions, nuxt.options.image, defaults)

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

// Normalize alias to start with leading slash
options.alias = Object.fromEntries(Object.entries(options.alias).map(e => [withLeadingSlash(e[0]), e[1]]))
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6919,10 +6919,10 @@ ip@^1.1.5:
resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.8.tgz#ae05948f6b075435ed3307acce04629da8cdbf48"
integrity sha512-PuExPYUiu6qMBQb4l06ecm6T6ujzhmh+MeJcW9wa89PoAz5pvd4zPgN5WJV104mb6S2T1AwNIAaB70JNrLQWhg==

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

0 comments on commit c6c7085

Please sign in to comment.