feat: 修改 getDomain 函数以支持可选的小写转换参数;更新 getObject 函数的默认值

This commit is contained in:
kuaifan 2025-11-12 07:07:00 +00:00
parent 6a3e3c3753
commit 2f32b53d19
2 changed files with 4 additions and 3 deletions

View File

@ -274,10 +274,11 @@ const utils = {
* @param weburl
* @returns {string|string}
*/
getDomain(weburl) {
getDomain(weburl, toLowerCase = true) {
const urlReg = /http(s)?:\/\/([^\/]+)/i;
const domain = `${weburl}`.match(urlReg);
return ((domain != null && domain.length > 0) ? domain[2] : "");
const result = ((domain != null && domain.length > 0) ? domain[2] : "");
return toLowerCase ? result.toLowerCase() : result;
},
/**

View File

@ -518,7 +518,7 @@ const timezone = require("dayjs/plugin/timezone");
* @param defaultValue
* @returns {string|*}
*/
getObject(obj, keys, defaultValue = undefined) {
getObject(obj, keys, defaultValue = "") {
let keyArray;
if (typeof keys === 'string') {
keyArray = keys.replace(/,/g, "|").replace(/\./g, "|").split("|");