Skip to content

Commit

Permalink
Only percent-decode uri (#19)
Browse files Browse the repository at this point in the history
* only decode uri

* release 0.0.5

* lint
  • Loading branch information
shiyuhang0 authored Sep 20, 2023
1 parent 9ac74b8 commit 44ecdb0
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tidbcloud/serverless",
"version": "0.0.4",
"version": "0.0.5",
"description": "TiDB Serverless driver",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
18 changes: 3 additions & 15 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,18 @@ export class Connection {
if (config.url) {
const url = new URL(config.url)
if (!this.config.username) {
this.config.username = url.username
this.config.username = decodeURIComponent(url.username)
}
if (!this.config.password) {
this.config.password = url.password
this.config.password = decodeURIComponent(url.password)
}
if (!this.config.host) {
this.config.host = url.hostname
}
if (!this.config.database) {
this.config.database = url.pathname.slice(1)
this.config.database = decodeURIComponent(url.pathname.slice(1))
}
}
// unescape password
if (this.config.password) {
this.config.password = decodeURIComponent(this.config.password)
}
// unescape database
if (this.config.database) {
this.config.database = decodeURIComponent(this.config.database)
}
// unescape username
if (this.config.username) {
this.config.username = decodeURIComponent(this.config.username)
}
}

async begin(): Promise<Tx> {
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const Version = '0.0.4'
export const Version = '0.0.5'

0 comments on commit 44ecdb0

Please sign in to comment.