Skip to content

Commit b812cb1

Browse files
committed
Fix downloading plugins on 127.0.0.1
1 parent c8c7e6e commit b812cb1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

handleRequest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,12 @@ async function resolvePluginOrSchemaUrl(url: URL) {
137137

138138
function getAccessControlAllowOrigin(request: Request) {
139139
const origin = request.headers.get("origin");
140-
return origin != null && isAllowedLocalHostname(new URL(origin).hostname)
140+
return origin != null && isLocalHostname(new URL(origin).hostname)
141141
? origin
142142
: "https://dprint.dev";
143143
}
144144

145-
function isAllowedLocalHostname(hostname: string) {
145+
function isLocalHostname(hostname: string) {
146146
return hostname === "localhost" || hostname === "127.0.0.1";
147147
}
148148

@@ -158,7 +158,7 @@ function shouldDirectlyServeFile(request: Request) {
158158
}
159159

160160
const hostname = new URL(origin).hostname;
161-
return hostname === "localhost" || hostname === "dprint.dev";
161+
return isLocalHostname(hostname) || hostname === "dprint.dev";
162162
}
163163

164164
function createRedirectResponse(location: string) {

0 commit comments

Comments
 (0)