Skip to content

Commit fbb4611

Browse files
authored
feat: use undecoded @path and @query according to the spec (#4)
1 parent b0a9e9b commit fbb4611

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/httpbis/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ export function deriveComponent(component: string, params: Map<string, string |
9393
throw new Error('Cannot derive @scheme on response');
9494
}
9595
const { pathname } = typeof context.url === 'string' ? new URL(context.url) : context.url;
96-
return [decodeURI(pathname)];
96+
// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures#section-2.2.6
97+
// empty path means use `/`
98+
return [pathname || '/'];
9799
}
98100
case '@query': {
99101
if (!isRequest(context)) {
@@ -102,7 +104,7 @@ export function deriveComponent(component: string, params: Map<string, string |
102104
const { search } = typeof context.url === 'string' ? new URL(context.url) : context.url;
103105
// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-message-signatures#section-2.2.7
104106
// absent query params means use `?`
105-
return [decodeURI(search) || '?'];
107+
return [search || '?'];
106108
}
107109
case '@query-param': {
108110
if (!isRequest(context)) {

0 commit comments

Comments
 (0)