eugef / node-mocks-http

Mock 'http' objects for testing Express routing functions
Other
747 stars 131 forks source link

Fix request.ip and add request.ips #244

Closed sergioregueira closed 2 years ago

sergioregueira commented 3 years ago

Changes:

According to express interface, the request.ip property must be always defined, so I have set 127.0.0.1 as the default value.

Additionally, I have also implemented the request.ips property.

Note:

Formally request.ip is defined as request.ips[0] but I made the decision to simplify the RequestOptions interface accepting only the ip property because it is the common case and it avoids inconsistencies between both options (when someone specifies an ip that is not the first element of ips).