File tree Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Expand file tree Collapse file tree 2 files changed +5
-12
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class MeiliSearch {
2727 httpRequest : HttpRequests
2828
2929 constructor ( config : Config ) {
30- config = addProtocolIfNotPresent ( config )
30+ config . host = addProtocolIfNotPresent ( config . host )
3131 config . host = HttpRequests . addTrailingSlash ( config . host )
3232 this . config = config
3333 this . httpRequest = new HttpRequests ( config )
Original file line number Diff line number Diff line change 1- import { Config } from '../types'
2-
31/**
42 * Removes undefined entries from object
53 */
@@ -15,16 +13,11 @@ async function sleep(ms: number): Promise<void> {
1513 return await new Promise ( ( resolve ) => setTimeout ( resolve , ms ) )
1614}
1715
18- function addProtocolIfNotPresent ( config : Config ) : Config {
19- if (
20- ! ( config . host . startsWith ( 'https://' ) || config . host . startsWith ( 'http://' ) )
21- ) {
22- return {
23- ...config ,
24- host : 'http://' + config . host ,
25- }
16+ function addProtocolIfNotPresent ( host : string ) : string {
17+ if ( ! ( host . startsWith ( 'https://' ) || host . startsWith ( 'http://' ) ) ) {
18+ return `http://${ host } `
2619 }
27- return config
20+ return host
2821}
2922
3023export { sleep , removeUndefinedFromObject , addProtocolIfNotPresent }
You can’t perform that action at this time.
0 commit comments