Skip to content

Commit

Permalink
Fix Toph parser
Browse files Browse the repository at this point in the history
  • Loading branch information
jmerle committed Aug 3, 2024
1 parent f044f11 commit fb325fc
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/parsers/problem/TophProblemParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import { Parser } from '../Parser';

export class TophProblemParser extends Parser {
public getMatchPatterns(): string[] {
return ['https://toph.co/p/*', 'https://toph.co/arena?contest=*/p/*'];
return ['https://toph.co/p/*', 'https://toph.co/arena?*=*/p/*'];
}

public async parse(url: string, html: string): Promise<Sendable> {
const elem = htmlToElement(html);
const task = new TaskBuilder('Toph').setUrl(url);

task.setName(elem.querySelector('.artifact h1').textContent);
task.setName(elem.querySelector('.artifact h1').textContent.replace(/\s+/g, ' ').trim());

const limitsStr = elem.querySelector('span.dotted[data-target="#mdlFactors"]').textContent;
const limitsStr = elem.querySelector('span.dotted.limits').textContent;

const [, timeAmount, timeUnit] = /([0-9.]+)(.*),/.exec(limitsStr);
task.setTimeLimit(parseFloat(timeAmount) * (timeUnit === 'ms' ? 1 : 1000));
Expand Down

0 comments on commit fb325fc

Please sign in to comment.