Skip to content

Commit

Permalink
Merge pull request #31 from ava-labs/hotfix
Browse files Browse the repository at this point in the history
Minor fixes
  • Loading branch information
rajranjan0608 authored Jun 24, 2022
2 parents 58b4b10 + b108693 commit a0a028c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion middlewares/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './rateLimiter'
export * from './verifyCaptcha'
export * from './verifyTOTP'
export * from './verifyTOTP'
export * from './parseURI'
12 changes: 12 additions & 0 deletions middlewares/parseURI.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const parseURI = (req: any, res: any, next: any) => {
var err = null;
try {
decodeURIComponent(req.path)
} catch(e) {
err = e
}
if(err) {
return res.redirect('/')
}
next();
}
2 changes: 1 addition & 1 deletion middlewares/rateLimiter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class RateLimiter {
keyGenerator: (req, res) => {
const ip = this.getIP(req)
if(ip != null) {
return ip + req.body?.chain
return ip
}
}
})
Expand Down
3 changes: 2 additions & 1 deletion server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import path from 'path'
import dotenv from 'dotenv'
import { BN } from 'avalanche'

import { RateLimiter, VerifyCaptcha } from './middlewares'
import { RateLimiter, VerifyCaptcha, parseURI } from './middlewares'
import EVM from './vms/evm'

import {
Expand All @@ -28,6 +28,7 @@ const router: any = express.Router()

app.use(express.static(path.join(__dirname, "client")))
app.use(cors())
app.use(parseURI)
app.use(bodyParser.json())

new RateLimiter(app, [GLOBAL_RL])
Expand Down

0 comments on commit a0a028c

Please sign in to comment.