@@ -25,15 +25,14 @@ import type {
2525 responses
2626} from '@ncharts/types' ;
2727
28+ import { hasOwnProperty , isBrowser , isObject , type Ctor } from '@noelware/utils' ;
2829import { DEFAULT_API_VERSION , DEFAULT_BASE_URL } from './constants' ;
29- import { hasOwnProperty , isBrowser , isObject } from '@noelware/utils' ;
30- import { transformJSON , transformYaml } from './internal' ;
30+ import { transformJSON , transformYaml , assert } from './internal' ;
3131import type { AbstractAuthStrategy } from './auth' ;
3232import { OrganizationContainer } from './containers/organizations' ;
3333import { ApiKeysContainer } from './containers/apikeys' ;
3434import { UserContainer } from './containers/users' ;
3535import { HTTPError } from './errors/HTTPError' ;
36- import assert from 'assert' ;
3736import defu from 'defu' ;
3837
3938export type HTTPMethod = 'get' | 'put' | 'head' | 'post' | 'patch' | 'delete' ;
@@ -42,7 +41,7 @@ export const Methods: readonly HTTPMethod[] = ['get', 'put', 'head', 'post', 'pa
4241/**
4342 * Fetch implementation blue-print.
4443 */
45- export type Fetch = ( input : RequestInit | URL , init ?: RequestInit ) => Promise < Response > ;
44+ export type Fetch = ( input : RequestInfo | URL , init ?: RequestInit ) => Promise < Response > ;
4645
4746/**
4847 * FormData implementation blue-print
@@ -80,7 +79,7 @@ export interface ClientOptions {
8079 * To avoid any errors when requesting data, you will need to install the [form-data](https://npm.im/form-data)
8180 * Node.js package to send form data.
8281 */
83- FormData ?: { new ( ... args : any [ ] ) : FormData } ;
82+ FormData ?: Ctor < FormData > ;
8483
8584 /**
8685 * Base URL to send requests to
@@ -158,7 +157,9 @@ export interface RequestOptions<R extends Route, Method extends HTTPMethod, Body
158157const kClientOptions = {
159158 apiVersion : DEFAULT_API_VERSION ,
160159 baseURL : DEFAULT_BASE_URL ,
161- headers : { }
160+ headers : {
161+ 'User-Agent' : 'Noelware/charted-sdk-js (+https://github.com/charted-dev/js-sdk)'
162+ }
162163} satisfies ClientOptions ;
163164
164165export class Client {
@@ -570,7 +571,7 @@ export class Client {
570571
571572 if ( url . match ( / { ( [ \w \. ] + ) } / g) && options !== undefined && hasOwnProperty ( options , 'pathParameters' ) ) {
572573 const params = options . pathParameters as Record < string , unknown > ;
573- formedUrl = formedUrl . replaceAll ( / ( [ \w \. ] + ) } / g, ( _ , key ) => {
574+ formedUrl = formedUrl . replaceAll ( / { ( [ \w \. ] + ) } / g, ( _ , key ) => {
574575 if ( hasOwnProperty ( params , key ) ) {
575576 return String ( params [ key ] ) ;
576577 }
@@ -596,6 +597,6 @@ export class Client {
596597 }
597598 }
598599
599- return formedUrl ;
600+ return formedUrl . replace ( / \/ + $ / , '' ) ;
600601 }
601602}
0 commit comments