mirror of
https://github.com/movie-web/providers.git
synced 2025-09-13 14:53:24 +00:00
Basically library structure
This commit is contained in:
15
src/fetchers/common.ts
Normal file
15
src/fetchers/common.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { FetcherOptions } from '@/fetchers/types';
|
||||
|
||||
// make url with query params and base url used correctly
|
||||
export function makeFullUrl(url: string, ops?: FetcherOptions): string {
|
||||
// glue baseUrl and rest of url together
|
||||
const fullUrl = ops?.baseUrl ?? '';
|
||||
// TODO make full url
|
||||
|
||||
const parsedUrl = new URL(fullUrl);
|
||||
Object.entries(ops?.query ?? {}).forEach(([k, v]) => {
|
||||
parsedUrl.searchParams.set(k, v);
|
||||
});
|
||||
|
||||
return parsedUrl.toString();
|
||||
}
|
Reference in New Issue
Block a user