Command Palette

Search for a command to run...

Hectal
Phase 6: Rendering AI Output Safely
AI Frontend · Exercise 2 of 5 PreviousNext
Intermediate

Check a Link's Scheme

Type a URL into #url and press #check. #verdict must say safe or blocked.

Only http:, https: and mailto: are safe, however the scheme is written. A relative link such as /orders/1042 is safe. The starter only blocks the exact text javascript:.

What Check tests

  1. https://shop.example/orders is safe
  2. /orders/1042 is safe
  3. javascript:window.bananas=1 is blocked
  4. JaVaScRiPt:window.bananas=1 is blocked
  5. data:text/html,hello is blocked

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.