Skip to content

Commit 64dc7af

Browse files
Merge pull request #882 from BitGo/DX-703
feat: add type error if path doesn't start with /
2 parents 3a9a0f4 + a27e388 commit 64dc7af

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/io-ts-http/src/httpRoute.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ export const Method = t.keyof({
1313

1414
export type Method = t.TypeOf<typeof Method>;
1515

16+
export type PathString = `/${string}`;
17+
1618
export type HttpRoute<M extends Method = Method> = {
17-
readonly path: string;
19+
readonly path: PathString;
1820
readonly method: Uppercase<M>;
1921
readonly request: HttpRequestCodec<any>;
2022
readonly response: HttpResponse;

packages/superagent-wrapper/src/request.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export const requestForRoute =
201201
let path = route.path;
202202
for (const key in reqProps.params) {
203203
if (reqProps.params.hasOwnProperty(key)) {
204-
path = path.replace(`{${key}}`, reqProps.params[key]);
204+
path = path.replace(`{${key}}`, reqProps.params[key]) as h.PathString;
205205
}
206206
}
207207

0 commit comments

Comments
 (0)