changes
This commit is contained in:
@@ -44,14 +44,15 @@ export default defineNuxtPlugin(() => {
|
||||
const filter = function (arr, obj, attr) {
|
||||
const keys = Object.keys(obj);
|
||||
|
||||
if (!arr) {
|
||||
console.error(`$filter: arr is ${arr}`);
|
||||
if (!Array.isArray(arr)) {
|
||||
console.error(`$filter: arr ${arr} is not an array`);
|
||||
return [];
|
||||
}
|
||||
|
||||
const rows = arr.filter((v) => {
|
||||
let valid = true;
|
||||
keys.map((key) => {
|
||||
|
||||
keys.forEach((key) => {
|
||||
let val = obj[key];
|
||||
if (valid === false) return false;
|
||||
else if (Array.isArray(val)) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
import isSameOrBefore from "dayjs/plugin/isSameOrBefore";
|
||||
import isSameOrAfter from "dayjs/plugin/isSameOrAfter";
|
||||
import "dayjs/locale/vi";
|
||||
import { deburr } from "es-toolkit";
|
||||
dayjs.extend(weekday);
|
||||
dayjs.extend(weekOfYear);
|
||||
dayjs.extend(relativeTime);
|
||||
@@ -213,24 +214,14 @@ export default defineNuxtPlugin((nuxtApp) => {
|
||||
};
|
||||
|
||||
const nonAccent = function (str) {
|
||||
if ($empty(str)) return null;
|
||||
str = str.replaceAll("/", "-").replaceAll("%", "-").replaceAll("?", "-");
|
||||
str = str.toLowerCase();
|
||||
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
|
||||
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
|
||||
str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
|
||||
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
|
||||
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
|
||||
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
|
||||
str = str.replace(/đ/g, "d");
|
||||
// Some system encode vietnamese combining accent as individual utf-8 characters
|
||||
str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // Huyền sắc hỏi ngã nặng
|
||||
str = str.replace(/\u02C6|\u0306|\u031B/g, ""); // Â, Ê, Ă, Ơ, Ư
|
||||
str = str
|
||||
.split(" ")
|
||||
.filter((s) => s)
|
||||
.join("-");
|
||||
return str;
|
||||
if ($empty(str)) return "";
|
||||
const result = deburr(str)
|
||||
.toLowerCase()
|
||||
.replaceAll(/\u02C6/g, "") // 'ˆ' (Some system encode vietnamese combining accent as individual utf-8 characters)
|
||||
.replaceAll(/[\/%?]/g, " ")
|
||||
.replaceAll(/[\s-]+/g, "-");
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
const linkID = function (link) {
|
||||
|
||||
Reference in New Issue
Block a user