veliovgroup / spiderable-middleware

🤖 Prerendering for JavaScript powered websites. Great solution for PWAs (Progressive Web Apps), SPAs (Single Page Applications), and other websites based on top of front-end JavaScript frameworks
https://www.npmjs.com/package/spiderable-middleware
BSD 3-Clause "New" or "Revised" License
38 stars 4 forks source link

Possible incorrect regex for header test #6

Closed arabidopsis closed 4 years ago

arabidopsis commented 4 years ago

The line:

https://github.com/VeliovGroup/spiderable-middleware/blob/05078ab58400307f2acdbfeec3f56f651e5e76ac/lib/index.js#L102

should probably be:

this.headersRE = new RegExp('^' + this.ignoredHeaders.join(strs.pipe) + '$', 'i');

otherwise you will match 'user-agent' for example since it has 'age' in it.

dr-dimitru commented 4 years ago

@arabidopsis then it also should be wrapped with parentheses like

new RegExp('^(' + this.ignoredHeaders.join(strs.pipe) + ')$', 'i');

Or I'd prefer ES6:

new RegExp(`^(${this.ignoredHeaders.join(strs.pipe))$`, 'i');
dr-dimitru commented 4 years ago

Hello @arabidopsis ,

Thank you a lot for reporting this one, please update to v1.6.2

Feel free to close it in case if the issue is solved on your end.

dr-dimitru commented 4 years ago

Closed due to silence at issue owner end. Feel free to reopen it in case if the issue still persists on your end.