p-meier / hapi-api-version

An API versioning plugin for hapi.
Apache License 2.0
74 stars 26 forks source link

Hapi v18 compatibility: Cannot read property 'slice' of undefined #27

Closed kdd-xiaoxianrou closed 5 years ago

kdd-xiaoxianrou commented 5 years ago

Hello,

I am using hapi-api-version for my project. And I am updating version of hapi, so hapi-api-version.

Hapi: 18.1.0 Hapi-api-version: 2.1.2

I have this issue:

TypeError: Cannot read property 'slice' of undefined
    at server.ext (/var/www/node_modules/hapi-api-version/index.js:136:89)
    at module.exports.internals.Manager.execute (/var/www/node_modules/hapi/lib/toolkit.js:31:106)
    at Request._invoke (/var/www/node_modules/hapi/lib/request.js:339:55)
    at Request._onRequest (/var/www/node_modules/hapi/lib/request.js:230:41)
    at Request._execute (/var/www/node_modules/hapi/lib/request.js:212:24)
    at internals.Queue.add (/var/www/node_modules/hapi/lib/core.js:658:21)
    at Server.<anonymous> (/var/www/node_modules/hapi/lib/core.js:488:24)
    at Server.emit (events.js:189:13)
    at parserOnIncoming (_http_server.js:672:12)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:109:17)

And i think bug come with new format of request.url. Which contains some Symbol. And not longer an object.

timcosta commented 5 years ago

This is a known issue with hapi 18 because it uses a new url parser. It will be fixed soon, but a PR is welcome if you need it ASAP

kdd-xiaoxianrou commented 5 years ago

I tried to do something, but i don't really know this new parser, with "Symbol('context')". Can you guide me a bit ? Thank you :)

timcosta commented 5 years ago

v2.2.0 has been released with hapi 17 + 18 compatibility.