4 ms·
In this line: https://github.com/brannondorsey/host-validation/blob/2ba4672b82e2d956dd8614c87e2d846505be18d6/index.js#L91 https://github.com/brannondorsey/host-
by partycoder 8y ago
In this line: https://github.com/brannondorsey/host-validation/blob/2ba4672b82e2d956dd8614c87e2d846505be18d6/index.js#L91 https://github.com/brannondorsey/host-validation/blob/2ba467... use Array.some rather than iterating through all elements with Array.filter.
Then this: https://github.com/brannondorsey/host-validation/blob/2ba4672b82e2d956dd8614c87e2d846505be18d6/index.js#L28 https://github.com/brannondorsey/host-validation/blob/2ba467... is not something I would recommend. Don't try to fix bad input.
- braxxox 8y ago#1, good call! #2, usually I am 100% in agreement. But referer vs referrer in the HTTP spec is a special case. I chose to do this as referer is misspelled in the spec itself.
- partycoder 8y agoDoes the misspelled version prevailed over the correct version if both are defined?
- braxxox 8y agoIt does as it is the correct header name.
- wild_preference 8y agoIf both keys exist, then it’s an even bigger signal of user mistake. Are you going to fail then? Distinction becomes pretty arbitrary. As a user, I’d rather have a failure at boot time if I got it wrong. Just because I had a typo once doesn’t mean I always make it. What if I tried to transform my own config? I’d have to follow special case your referers property like you did to keep it consistent.
- partycoder 8y agoMay be a reasonable choice but I recommend just throwing.