File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
packages/faucet-client/src Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 1
1
import fetch from "cross-fetch" ;
2
2
3
+ /**
4
+ * Strip trailing `/`s
5
+ */
6
+ function stripTrailingSlash ( baseUrl : string ) : string {
7
+ // Limit the amount of / stripped to avoid potential regex DoS
8
+ return baseUrl . replace ( / ( \/ { 0 , 20 } ) $ / , "" ) ;
9
+ }
10
+
3
11
export class FaucetClient {
4
12
private readonly baseUrl : string ;
5
13
6
14
public constructor ( baseUrl : string ) {
7
15
if ( ! baseUrl . match ( / ^ h t t p s ? : \/ \/ / ) ) {
8
16
throw new Error ( "Expected base url to start with http:// or https://" ) ;
9
17
}
10
-
11
- // Strip trailing /
12
- const strippedBaseUrl = baseUrl . replace ( / ( \/ + ) $ / , "" ) ;
13
- this . baseUrl = strippedBaseUrl ;
18
+ this . baseUrl = stripTrailingSlash ( baseUrl ) ;
14
19
}
15
20
16
21
public async credit ( address : string , denom : string ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments