jsonapi-rb / jsonapi-renderer

Efficiently render JSON API documents.
http://jsonapi-rb.org
MIT License
27 stars 11 forks source link

JSONAPI::IncludeDirective::InvalidKey raised when includes underscore #37

Closed SirRawlins closed 5 years ago

SirRawlins commented 5 years ago

Good morning folks. 👋

Just bumped to 0.2.1 which includes #36. I have now started receiving JSONAPI::IncludeDirective::InvalidKey errors for keys which include (but don't begin or end with) an underscore.

Reading the specification it suggests that underscores are allowed, so long as they're not at the beginning or end?

I'm horrible at working with REGEX so putting together a fix is a bit outside of my ability, otherwise, I'd put together a PR.

InteNs commented 5 years ago

I'm having the same issue

Japestrale commented 5 years ago

I'm also experiencing this

d--j commented 5 years ago

This regular expression should work /^(?![ \-_])[\u0080-\u10FFFFA-Za-z0-9_ -]+(?<![ \-_])$/ . (added -, _ and ` (space) as valid characters, removed*` since it is not valid)

Test here: https://rubular.com/r/s5bUXhkj2gpGzl

jonmast commented 5 years ago

I've opened a PR with a fix: #38

Fix is similar to @d--j's suggestion but keeps the star in, while it is not valid in key names it's used as a wildcard in includes.

nesrual commented 5 years ago

Same problem here - reverting to 0.2.0 solves the problem

mihairadulescu commented 5 years ago

same issue here .. image

beauby commented 5 years ago

@dawidof This needs attention when you get a chance