Skip to content

Commit

Permalink
fix: matching rules of uri
Browse files Browse the repository at this point in the history
  • Loading branch information
memset0 committed Jul 22, 2024
1 parent 984a1f2 commit 2228ea0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import ModuleVjudge from './modules/vjudge/main';
import ModuleCodeforces from './modules/codeforces/main';

export default class App {
modules: Dict<Module>
_queuedPlugins: Dict<Array<{ feature: Feature, func: () => void }>>
modules: Dict<Module>;
_queuedPlugins: Dict<Array<{ feature: Feature; func: () => void }>>;

log(...args: any[]) {
return console.log('[CPAssistant.js]', ...args);
Expand Down Expand Up @@ -41,4 +41,4 @@ export default class App {

export const app = new App();
app.register(new ModuleVjudge(app));
app.register(new ModuleCodeforces(app));
app.register(new ModuleCodeforces(app));
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const config: Dict<any> = {
],
vjudge: [
'vjudge.net',
'vjudge.net.cn',
'cn.vjudge.net',
'vjudge.z180.cn',
],
Expand Down
8 changes: 7 additions & 1 deletion src/types/feature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,14 @@ export default class Feature {
const args: Dict<string> = {}
const matchParts = match.slice(1).split('/')
const pathParts = location.pathname.slice(1).split('/')
if (matchParts[matchParts.length - 1] == '') {
--matchParts.length;
}
if (pathParts[pathParts.length - 1] == '') {
--pathParts.length;
}

if (pathParts.length < matchParts.length) {
if (pathParts.length != matchParts.length) {
return false
}

Expand Down

0 comments on commit 2228ea0

Please sign in to comment.