mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-03 06:07:19 +02:00
Optimize Game slug generator by using cached RegEx
This commit is contained in:
parent
33c3b2810a
commit
8a3d48d4a3
3
build.ts
3
build.ts
@ -100,6 +100,9 @@ const postProcess = (str: string): string => {
|
||||
});
|
||||
}
|
||||
|
||||
// Fix unicode regex in Patcher.optimizeGameSlugGenerator
|
||||
str = str.replaceAll('^\\™', '^\\\\u2122');
|
||||
|
||||
assert(str.includes('/* ADDITIONAL CODE */'));
|
||||
assert(str.includes('window.BX_EXPOSED = BxExposed'));
|
||||
assert(str.includes('window.BxEvent = BxEvent'));
|
||||
|
@ -972,6 +972,19 @@ if (this.baseStorageKey in window.BX_EXPOSED.overrideSettings) {
|
||||
return str;
|
||||
},
|
||||
|
||||
// Optimize Game slug generator by using cached RegEx
|
||||
optimizeGameSlugGenerator(str: string) {
|
||||
let text = '/[;,/?:@&=+_`~$%#^*()!^\\u2122\\xae\\xa9]/g';
|
||||
if (!str.includes(text)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
str = str.replace(text, 'window.BX_EXPOSED.GameSlugRegexes[0]');
|
||||
str = str.replace('/ {2,}/g', 'window.BX_EXPOSED.GameSlugRegexes[1]');
|
||||
str = str.replace('/ /g', 'window.BX_EXPOSED.GameSlugRegexes[2]');
|
||||
|
||||
return str;
|
||||
},
|
||||
};
|
||||
|
||||
let PATCH_ORDERS: PatchArray = [
|
||||
@ -982,6 +995,8 @@ let PATCH_ORDERS: PatchArray = [
|
||||
'exposeInputSink',
|
||||
] : []),
|
||||
|
||||
'optimizeGameSlugGenerator',
|
||||
|
||||
'detectBrowserRouterReady',
|
||||
'patchRequestInfoCrash',
|
||||
|
||||
|
@ -144,4 +144,10 @@ export const BxExposed = {
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
GameSlugRegexes: [
|
||||
/[;,/?:@&=+_`~$%#^*()!^\u2122\xae\xa9]/g,
|
||||
/ {2,}/g,
|
||||
/ /g,
|
||||
],
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user