Skip to content
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
9 changes: 9 additions & 0 deletions src/fetch/index.t-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,13 @@ import JSONT from "../json";
headers: { Cookie: "a=b" },
});
})();

(async () => {
// basePathの最後にも/があるのでhttps://example.com/api//usersとなってしまうが、ノーマライズされるので問題ない
const basePath = "https://example.com/api/";
const f = fetch as FetchT<typeof basePath, Spec>;
await f(`${basePath}/users`, {
headers: { Cookie: "a=b" },
});
})();
}
6 changes: 3 additions & 3 deletions src/fetch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ type FetchT<UrlPrefix extends UrlPrefixPattern, E extends ApiEndpoints> = <
Input extends
| `${ToUrlParamPattern<UrlPrefix>}${ToUrlParamPattern<keyof E & string>}`
| `${ToUrlParamPattern<UrlPrefix>}${ToUrlParamPattern<keyof E & string>}?${string}`,
InputPath extends ParseURL<
Replace<NormalizePath<Input>, NormalizePath<UrlPrefix>, "">
>["path"],
InputPath extends NormalizePath<
ParseURL<Replace<Input, UrlPrefix, "">>["path"]
>,
CandidatePaths extends MatchedPatterns<InputPath, keyof E & string>,
InputMethod extends CaseInsensitiveMethod = "get",
M extends Method = Lowercase<InputMethod>,
Expand Down