Skip to content

Commit

Permalink
Fix dev binding parsing for hyperdrive to correctly format address (#727
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tmthecoder authored and mrbbot committed Nov 1, 2023
1 parent a098c7d commit 6bdf26c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/miniflare/src/plugins/hyperdrive/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,15 @@ export const HyperdriveSchema = z
"You must provide a hostname or IP address in your connection string - e.g. 'user:[email protected]:5432/databasename",
});
}
if (url.port === "") {
let port: string | undefined;
if (
url.port === "" &&
(url.protocol === "postgresql:" || url.protocol == "postgres:")
) {
port = "5432";
} else if (url.port !== "") {
port = url.port;
} else {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message:
Expand Down Expand Up @@ -65,8 +73,8 @@ export const HyperdriveSchema = z
user: url.username,
password: url.password,
scheme: url.protocol.replace(":", ""),
host: url.host,
port: url.port,
host: url.hostname,
port: port,
};
});

Expand Down

0 comments on commit 6bdf26c

Please sign in to comment.