Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing media types with '.' in them #36

Merged
merged 1 commit into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/Cro/MediaType.pm6
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Cro::MediaType {
}
token qtext { <-["\\\n]>+ }
token quoted-pair { \\ <( . )> }
token token { <[A..Za..z0..9!#$%&'*+^_`{|}~-]>+ }
token token { <[A..Za..z0..9!#$%&'*+^_`{|}~\.-]>+ }
}

class Actions {
Expand Down
10 changes: 10 additions & 0 deletions t/mediatype.t
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ parses 'text/plain; charset=UTF-8;', 'Media type with stray ; after parameter',
is .Str, 'text/plain; charset=UTF-8', 'Stringifies correctly';
};

parses 'application/json; charset=utf-8; api-version=7.1-preview.1', 'Media type with . in parameter', {
is .type, 'application', 'Correct type';
is .subtype, 'json', 'Correct subtype';
is .subtype-name, 'json', 'Correct subtype name';
is .tree, '', 'No tree';
is .suffix, '', 'No suffix';
is-deeply .parameters.List, ('charset' => 'utf-8', api-version => '7.1-preview.1'), 'Correct parameters';
is .Str, 'application/json; charset=utf-8; api-version=7.1-preview.1', 'Stringifies correctly';
};

parses 'text/plain;', 'Media type with stray ; at end, but no parameters', {
is .type, 'text', 'Correct type';
is .subtype, 'plain', 'Correct subtype';
Expand Down