Fix CourseBook term validation to accept uppercase semesters and reject partial matches

Aperta Adatta ai principianti
#216 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
go
Ambito
cli

Direzione di ricerca

Inizia dalla dichiarazione di termRegex e dalla relativa chiamata a MatchString in scrapers/coursebook.go, dove ScrapeCoursebook valida il termine prima della configurazione. Leggi l'esempio del README che usa -term 24F per confermare l'input previsto. È completato quando 24F, 24f, 26S e 26u vengono accettati e normalizzati in minuscolo, mentre 4f, 124f, 24fextra, abc24f e 24X vengono rifiutati con un errore chiaro prima dell'avvio del browser.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

CourseBook term validation uses the unanchored regex [0-9]{1,2}[sfu] in scrapers/coursebook.go.

This causes two problems:

  • Uppercase terms such as 24F, as documented in the README, are rejected.
  • Malformed terms such as 4f, 124f, and 24fextra pass validation because the regex accepts a matching substring.

Expected behavior:

  • Accept exactly two digits followed by S, U, or F, case-insensitively.
  • Normalize accepted terms to the lowercase format used by the CourseBook scraper before further processing.
  • Reject malformed terms with a clear error before initializing the browser or making requests.
Steps To Reproduce
  1. Build the executable with make build (or build.bat build on Windows).
  2. Run the documented command:
    ./api-tools -scrape -coursebook -term 24F
    
  3. Observe that validation rejects the uppercase semester.
  4. Inspect termRegex and its MatchString call in scrapers/coursebook.go: the pattern also accepts 4f, 124f, and 24fextra.

Malformed values that pass validation proceed toward browser initialization, so inspecting the regex is sufficient to confirm that behavior without starting a scrape.

Additional Context

Starting points:

Suggested manual checks:

  • Accept 24F, 24f, 26S, and 26u.
  • Reject 4f, 124f, 24fextra, abc24f, and 24X.
  • Confirm accepted terms reach scraper setup in the same normalized format.

Keep this task limited to term validation and normalization. Broader scraper error handling is covered by #192.

Environment

Identified by source inspection of commit 3f3585e; not reproduced by executing the scraper. The regex behavior is platform-independent.

Lingua principale
Go
Stelle
12
Fork
54
Merge medio
14g 1h
PR unite (30g)
1

Preparare l'ambiente

  • Include un Dockerfile o un file Docker Compose
  • Ha un modello di pull request
  • Nessuna guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di UTDNebula/api-tools

Tutte le issue di UTDNebula/api-tools

Issue simili

Altre issue su Go

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.