pillarjs / path-to-regexp

Turn a path string such as `/user/:name` into a regular expression

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Params object has no prototype

lesjames opened this issue · comments

I ran into an issue with the params object being returned from match. I do an equality check on the params object and it was causing an error because the params object is being created without a prototype.

const params = Object.create(null);

See some common issues when an object is created with no prototype.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create#custom_and_null_objects

This is to help mitigate the risks of prototype pollution.

Ah, good to know. Thank you.