Shamoon
Shamoon

Reputation: 43531

Express regular expression matching

app.get('/api/transactions/:hash([0-9a-fA-F]{64})', transaction.get);

I want anything that goes to /api/transactions/SOMEHASH to be picked up by that route. All hashes will be 64 characters and be hex. However, this doesn't seem to work. Ideas?

Upvotes: 0

Views: 68

Answers (1)

Casimir et Hippolyte
Casimir et Hippolyte

Reputation: 89557

Try this:

app.param('hash', /^[0-9a-fA-F]{64}$/);
app.get('/api/transactions/:hash', transaction.get);

Upvotes: 2

Related Questions