Skip to content

Commit

Permalink
feat: reduce dsn regexp character lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
belgattitude committed Oct 20, 2023
1 parent 34432cc commit 8681dc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/slimy-pots-glow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@httpx/dsn-parser': minor
---

Reduce dsn regexp character lengths (reduce complexity)
4 changes: 2 additions & 2 deletions packages/dsn-parser/src/parse-dsn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {
import { parseQueryParams } from './query-param-parser';

const dsnRegexp =
// eslint-disable-next-line regexp/no-unused-capturing-group
/^(?<driver>([\w+-]{1,45})):\/\/((?<user>[^/:]{1,200})?(:(?<pass>.{0,250}))?@)?(?<host>[^/:]{1,400}?)(:(?<port>\d+)?)?(\/(?<db>([.#@$\w-])+))?(\?(?<params>.{1,8196}))?$/;
// eslint-disable-next-line regexp/no-unused-capturing-group,regexp/no-misleading-capturing-group
/^(?<driver>([\w+-]{1,40})):\/\/((?<user>[^/:]{1,200})?(:(?<pass>.{0,200}))?@)?(?<host>[^/:]{1,200}?)(:(?<port>\d+)?)?(\/(?<db>([.#@$\w-])+))?(\?(?<params>.{1,1000}))?$/;

const defaultOptions = {
lowercaseDriver: false,
Expand Down

0 comments on commit 8681dc7

Please sign in to comment.