Skip to content

Commit

Permalink
feat: ProxyUtils.removeFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Jun 2, 2024
1 parent 99d058b commit b6f848a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.14.330",
"version": "2.14.331",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
3 changes: 2 additions & 1 deletion backend/src/core/proxy-utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import $ from '@/core/app';
import { FILES_KEY, MODULES_KEY } from '@/constants';
import { findByName } from '@/utils/database';
import { produceArtifact } from '@/restful/sync';
import { getFlag, getISO, MMDB } from '@/utils/geo';
import { getFlag, removeFlag, getISO, MMDB } from '@/utils/geo';
import Gist from '@/utils/gist';

function preprocess(raw) {
Expand Down Expand Up @@ -276,6 +276,7 @@ export const ProxyUtils = {
isIP,
yaml: YAML,
getFlag,
removeFlag,
getISO,
MMDB,
Gist,
Expand Down
9 changes: 1 addition & 8 deletions backend/src/core/proxy-utils/processors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import resourceCache from '@/utils/resource-cache';
import scriptResourceCache from '@/utils/script-resource-cache';
import { isIPv4, isIPv6 } from '@/utils';
import { FULL } from '@/utils/logical';
import { getFlag } from '@/utils/geo';
import { getFlag, removeFlag } from '@/utils/geo';
import lodash from 'lodash';
import $ from '@/core/app';
import { hex_md5 } from '@/vendor/md5';
Expand Down Expand Up @@ -869,13 +869,6 @@ function clone(object) {
return JSON.parse(JSON.stringify(object));
}

// remove flag
function removeFlag(str) {
return str
.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g, '')
.trim();
}

function createDynamicFunction(name, script, $arguments) {
const flowUtils = {
getFlowField,
Expand Down
7 changes: 7 additions & 0 deletions backend/src/utils/geo.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,13 @@ export function getISO(name) {
return ISOFlags[getFlag(name)]?.[0];
}

// remove flag
export function removeFlag(str) {
return str
.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g, '')
.trim();
}

export class MMDB {
constructor({ country, asn } = {}) {
if ($.env.isNode) {
Expand Down
3 changes: 3 additions & 0 deletions scripts/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,15 @@ function operator(proxies = [], targetPlatform, context) {
// isIP,
// yaml, // yaml 解析和生成
// getFlag, // 获取 emoji 旗帜
// removeFlag, // 移除 emoji 旗帜
// getISO, // 获取 ISO 3166-1 alpha-2 代码
// Gist, // Gist 类
// }

// 示例: 给节点名添加前缀
// $server.name = `[${ProxyUtils.getISO($server.name)}] ${$server.name}`
// 示例: 给节点名添加旗帜
// $server.name = `[${ProxyUtils.getFlag($server.name).replace(/🇹🇼/g, '🇼🇸')}] ${ProxyUtils.removeFlag($server.name)}`

// 示例: 从 sni 文件中读取内容并进行节点操作
// const sni = await produceArtifact({
Expand Down

0 comments on commit b6f848a

Please sign in to comment.