日照项目的居民端小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
524 B

/**
* 给字符串加统一前缀
*
* @type signature
* String a -> String b -> String c
* String a -> [String b] -> [String c]
* String a -> {x: String b} -> {x: String c}
*/
export default function jointPrefix(pre, url) {
if (typeof url === 'object') {
Object.keys(url).forEach((k) => {
url[k] = jointPrefix(pre, url[k]);
});
} else if (Array.isArray(url)) {
url = url.map(item => jointPrefix(pre, item));
} else if (typeof url === 'string') {
url = pre + url;
}
return url;
}