Skip to content

Commit

Permalink
fix: throw error on incorrectly formatted rewrite rules
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKreil committed Jun 18, 2024
1 parent b8c0984 commit 5695516
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ program
const rewriteRules: [string, string][] = Array.from(cmdOptions.rewriteRule as Iterable<unknown>).map(r => {
const parts = String(r).split(':');
if (parts.length !== 2) throw Error('a rewrite rule must be formatted as "$request:$origin"');
if (!parts[0].startsWith('/') || !parts[1].startsWith('/')) {
throw Error(`each side of a rewrite rule must start with a "/", e.g. "/public:/origin", but this rule is formatted as "${String(r)}"`);
}
return parts as [string, string];
});

Expand Down

0 comments on commit 5695516

Please sign in to comment.