Skip to content

Commit

Permalink
fix: uri parsing incorrectly extracting protocols
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael committed Nov 25, 2022
1 parent 14b469f commit 0e6eea8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import type { MethodsUpper } from "./types";
// currently only http and https are supported

// regex to get the protocol from the uri component, can match anything
export const PROTOCOL_REGEXP = /^([a-z0-9]+):\/\//i;
// should return http or https
export const PROTOCOL_REGEXP = /^(?:([a-z]+):\/\/)?([^:\/\n]+)/i;
export const HOSTNAME_REGEXP = /^(?:https?:\/\/)?(?:[^@\/\n]+@)?([^:\/\n]+)/i;
export const PORT_REGEXP = /:(\d{2,5})$/;

Expand Down

0 comments on commit 0e6eea8

Please sign in to comment.