Skip to content

Commit f45b6c7

Browse files
committed
yarn lint --fix
1 parent 9c15d08 commit f45b6c7

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/lib/masking.ts

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
1-
import { json } from "express";
1+
import { json } from 'express'
22

3-
export const maskSecretValue = <T>(resource: T, path: string): T => {
3+
export const maskSecretValue = <T>(resource: T, path: string): T => {
4+
const parts = path.split('.')
5+
const clone = JSON.parse(JSON.stringify(resource))
6+
let val = clone
47

5-
const parts = path.split(".")
6-
const clone = JSON.parse(JSON.stringify(resource))
7-
let val = clone
8+
const target = parts.pop()
9+
for (let i = 0; i < parts.length; i++) {
10+
const part = parts[i]
11+
val = val[part]
812

9-
const target = parts.pop()
10-
for (let i = 0; i < parts.length; i++) {
11-
const part = parts[i]
12-
val = val[part]
13-
14-
if (val == undefined) {
15-
return resource
16-
}
13+
if (val == undefined) {
14+
return resource
1715
}
16+
}
1817

19-
20-
if (val && target && val[target]) {
21-
val[target] = "****"
22-
}
23-
return clone
18+
if (val && target && val[target]) {
19+
val[target] = '****'
2420
}
21+
return clone
22+
}

src/repositories/project.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ export class ProjectRepository extends AbstractRepository {
2424
get(projectKey: string): Project | null {
2525
const data = this._storage.getProject(projectKey)
2626
const resource = this._storage.getProject(projectKey)
27-
const masked = maskSecretValue<Project>(resource, "externalOAuth.authorizationHeader")
27+
const masked = maskSecretValue<Project>(
28+
resource,
29+
'externalOAuth.authorizationHeader'
30+
)
2831
return masked
2932
}
3033

0 commit comments

Comments
 (0)