2022-11-16 15:01:34 +00:00
|
|
|
import { getAppDefaultUri, getAppMountUri } from "@saleor/config";
|
2021-05-14 08:15:15 +00:00
|
|
|
import isArray from "lodash/isArray";
|
2020-05-14 09:30:32 +00:00
|
|
|
import { stringify } from "qs";
|
2019-11-05 16:06:47 +00:00
|
|
|
|
2022-10-26 11:19:20 +00:00
|
|
|
export function stringifyQs(params: {}, arrayFormat?: string): string {
|
2019-11-05 16:06:47 +00:00
|
|
|
return stringify(params, {
|
2022-10-26 11:19:20 +00:00
|
|
|
arrayFormat: arrayFormat || "indices",
|
2019-11-05 16:06:47 +00:00
|
|
|
});
|
|
|
|
}
|
2020-01-20 15:12:20 +00:00
|
|
|
|
|
|
|
export function getArrayQueryParam(param: string | string[]): string[] {
|
|
|
|
if (!param) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isArray(param)) {
|
|
|
|
return param;
|
|
|
|
}
|
|
|
|
|
|
|
|
return [param];
|
|
|
|
}
|
2022-05-06 08:59:55 +00:00
|
|
|
|
|
|
|
export const isExternalURL = url => /^https?:\/\//.test(url);
|
2022-11-16 15:01:34 +00:00
|
|
|
|
|
|
|
export const getAppMountUriForRedirect = () =>
|
|
|
|
getAppMountUri() === getAppDefaultUri() ? "" : getAppMountUri();
|