EasyPro challengeJavaScriptTypeScript

Open Redirect — Only Allow Relative Paths

TypeScriptSecurityUnvalidated Redirects

A post-login "redirect back to where you came from" feature takes a returnTo URL from the query string and redirects there unchecked.

The bug: ?returnTo=https://evil-lookalike.com/login sends a freshly-authenticated user straight to a phishing page — and because the redirect started on the real, trusted domain, it's far more convincing than a cold phishing link. Protocol-relative URLs (//evil.com) are an easy-to-miss bypass of a naive check too.

Your task: fix solve(url) so it returns url unchanged only when it's a same-site relative path (starts with / but not //) — otherwise it returns the safe fallback '/'.

Sample tests

Test #1Safe same-site relative path
Input: ["/dashboard"]
Output: "/dashboard"
Test #2Absolute external URL blocked
Input: ["https://evil.com"]
Output: "/"
Test #3Protocol-relative URL bypass blocked
Input: ["//evil.com"]
Output: "/"