saleor-dashboard/src/utils/urls.ts

27 lines
652 B
TypeScript
Raw Normal View History

import { getAppDefaultUri, getAppMountUri } from "@saleor/config";
import isArray from "lodash/isArray";
import { stringify } from "qs";
2019-11-05 16:06:47 +00:00
export function stringifyQs(params: {}, arrayFormat?: string): string {
2019-11-05 16:06:47 +00:00
return stringify(params, {
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];
}
export const isExternalURL = url => /^https?:\/\//.test(url);
export const getAppMountUriForRedirect = () =>
getAppMountUri() === getAppDefaultUri() ? "" : getAppMountUri();