← 返回 tesla 的题目列表URL Normalizer
类型:online_judge
Implement the function normalize(url: str) -> str, which receives a URL and returns its normalized form. Simplification rules include a default protocol of http and a default domain of localhost. Other specific parts should be filled with defaults if absent.
Input:
A string url, representing a potentially incomplete URL.
Output:
A string representing the normalized URL.
Examples:
Input: "http://example.com:8080/a/b/c"
Output: "http://example.com:8080/a/b/c"
Input: "example.com"
Output: "http://example.com"
Input: "/a/b/c"
Output: "http://localhost/a/b/c"
Example
Input
http://example.com:8080/a/b/c