Skip to content

Commit

Permalink
fix: update dist
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeSiu committed Mar 24, 2024
1 parent a73a495 commit 3373e27
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
4 changes: 2 additions & 2 deletions dist/index.d.mts
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ interface XCRecording {
* @param {string} query - The query string to be appended to the base URL.
* @param {XCQueryOption} [options] - Optional additional query options.
* @param {number} [page] - Optional page number.
* @return {URL} The constructed query URL.
* @return {URL | string} The constructed query URL.
*/
declare function constructQueryUrl(baseUrl: string, query: string, options?: XCQueryOption, page?: number): URL;
declare function constructQueryUrl(baseUrl: string, query: string, options?: XCQueryOption, page?: number): URL | string;
/**
* Converts an XCQueryOption object to a required URL string parameter format. For example: "grp:"birds" cnt:"United States" method:"field recording""
*
Expand Down
4 changes: 2 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,9 @@ interface XCRecording {
* @param {string} query - The query string to be appended to the base URL.
* @param {XCQueryOption} [options] - Optional additional query options.
* @param {number} [page] - Optional page number.
* @return {URL} The constructed query URL.
* @return {URL | string} The constructed query URL.
*/
declare function constructQueryUrl(baseUrl: string, query: string, options?: XCQueryOption, page?: number): URL;
declare function constructQueryUrl(baseUrl: string, query: string, options?: XCQueryOption, page?: number): URL | string;
/**
* Converts an XCQueryOption object to a required URL string parameter format. For example: "grp:"birds" cnt:"United States" method:"field recording""
*
Expand Down
16 changes: 13 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 13 additions & 3 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ var __async = (__this, __arguments, generator) => {

// src/utils/utils.ts
function constructQueryUrl(baseUrl, query, options, page) {
let url = new URL(baseUrl);
let url;
try {
url = new URL(baseUrl);
} catch (error) {
url = baseUrl;
}
let parms = new URLSearchParams();
const processedQuery = query.trim();
if (processedQuery) {
Expand All @@ -38,7 +43,12 @@ function constructQueryUrl(baseUrl, query, options, page) {
if (page) {
parms.append("page", String(page));
}
url.search = parms.toString();
if (typeof url === "object" && url instanceof URL) {
url.search = parms.toString();
} else {
const queryString = parms.toString();
url += (url.includes("?") ? "&" : "?") + queryString;
}
return url;
}
function convertXCQueryOptionToSearchParams(option) {
Expand Down Expand Up @@ -143,7 +153,7 @@ function search(query, options, page, additionalOptions) {
)
);
}
return Promise.resolve({ url, rawResponse, xcResponse });
return Promise.resolve({ url: new URL(url), rawResponse, xcResponse });
} catch (error) {
console.error(error);
return Promise.reject(
Expand Down
2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

0 comments on commit 3373e27

Please sign in to comment.