@dfeidao/fd-aw000036
Version:
转换url地址
17 lines (16 loc) • 616 B
JavaScript
define("index", ["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function query2url(query, url = window.location.href) {
const usp = new URLSearchParams();
for (const k in query) {
if (query.hasOwnProperty(k)) {
usp.append(k, String(query[k]));
}
}
const url_param = usp.toString();
const _url = url.split('?')[0] + (url_param && url_param.length !== 0 ? '?' + url_param : '');
return _url;
}
exports.default = query2url;
});