Skip to content

Commit

Permalink
feat(dsn-parser): support + char in driver (#510)
Browse files Browse the repository at this point in the history
  • Loading branch information
belgattitude committed Jul 30, 2023
1 parent f30b04d commit a02984c
Show file tree
Hide file tree
Showing 9 changed files with 118 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .changeset/popular-coats-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@httpx/dsn-parser': minor
---

Support '+' character in driver
2 changes: 1 addition & 1 deletion examples/nextjs-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@types/react": "18.2.17",
"@types/react-dom": "18.2.7",
"cross-env": "7.0.3",
"eslint": "8.45.0",
"eslint": "8.46.0",
"eslint-config-next": "13.4.12",
"postcss": "8.4.27",
"rimraf": "5.0.1",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"cross-env": "7.0.3",
"docsify": "4.13.1",
"docsify-cli": "4.4.4",
"eslint": "8.45.0",
"eslint": "8.46.0",
"husky": "8.0.3",
"is-ci": "3.0.1",
"lint-staged": "13.2.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/dsn-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"browserslist-to-esbuild": "1.2.0",
"cross-env": "7.0.3",
"es-check": "7.1.1",
"eslint": "8.45.0",
"eslint": "8.46.0",
"get-tsconfig": "4.6.2",
"npm-run-all": "4.1.5",
"publint": "0.2.0",
Expand Down
14 changes: 14 additions & 0 deletions packages/dsn-parser/src/__tests__/parse-dsn.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
import { parseDsn } from '../parse-dsn';

describe('parseDsn', () => {
describe('when driver is provided with special chars', () => {
it.each(['redis', 'Driver55', 'driver-4', '44_driver', 'redis+sentinel'])(
`should return %s`,
(driver) => {
expect(parseDsn(`${driver}://localhost`)).toStrictEqual({
success: true,
value: {
driver,
host: 'localhost',
},
});
}
);
});
describe('when provided dsn contains all options', () => {
it('should return the correct parsed params', () => {
expect(
Expand Down
2 changes: 1 addition & 1 deletion packages/dsn-parser/src/parse-dsn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
import { parseQueryParams } from './query-param-parser';

const dsnRegexp =
/^(?<driver>([\w-]+)):\/\/((?<user>[^/:]{1,200})?(:(?<pass>.{0,250}))?@)?(?<host>[^/:]{1,400}?)(:(?<port>\d+)?)?(\/(?<db>([.#@$\w-])+))?(\?(?<params>.+))?$/;
/^(?<driver>([\w+-]{1,45})):\/\/((?<user>[^/:]{1,200})?(:(?<pass>.{0,250}))?@)?(?<host>[^/:]{1,400}?)(:(?<port>\d+)?)?(\/(?<db>([.#@$\w-])+))?(\?(?<params>.{1,8196}))?$/;

const defaultOptions = {
lowercaseDriver: false,
Expand Down
6 changes: 3 additions & 3 deletions packages/exception/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@size-limit/file": "8.2.6",
"@size-limit/webpack": "8.2.6",
"@size-limit/webpack-why": "8.2.6",
"@swc/core": "1.3.71",
"@swc/core": "1.3.72",
"@types/jest": "29.5.3",
"@types/node": "20.4.5",
"@types/statuses": "2.0.1",
Expand All @@ -117,13 +117,13 @@
"cross-env": "7.0.3",
"error-cause-polyfill": "2.0.0",
"es-check": "7.1.1",
"eslint": "8.45.0",
"eslint": "8.46.0",
"get-tsconfig": "4.6.2",
"jest": "29.6.2",
"npm-run-all": "4.1.5",
"publint": "0.1.16",
"rimraf": "5.0.1",
"rollup": "3.26.3",
"rollup": "3.27.0",
"rollup-plugin-dts": "5.3.0",
"rollup-plugin-swc3": "0.9.0",
"size-limit": "8.2.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/json-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"browserslist-to-esbuild": "1.2.0",
"cross-env": "7.0.3",
"es-check": "7.1.1",
"eslint": "8.45.0",
"eslint": "8.46.0",
"get-tsconfig": "4.6.2",
"npm-run-all": "4.1.5",
"publint": "0.2.0",
Expand Down

0 comments on commit a02984c

Please sign in to comment.