fiora/packages/utils/url.ts
碎碎酱 ca7c13da05
Migrate to monorepo project (#413)
* Refactor as monorepo

* Fix server

* Fix client

* Fix not fire message event error

* Fix CI scripts

* Update install doc

* Fix bin

* Refactored the directory structure to the final version

* Fix ts type error

* Fix lint error

* Fix unit test error

* Update .gitignore
2021-07-19 21:21:34 +08:00

17 lines
427 B
TypeScript

interface UrlParams {
[key: string]: string;
}
// eslint-disable-next-line import/prefer-default-export
export function addParam(url: string, params: UrlParams) {
let result = url;
Object.keys(params).forEach((key) => {
if (result.indexOf('?') === -1) {
result += `?${key}=${params[key]}`;
} else {
result += `&${key}=${params[key]}`;
}
});
return result;
}