Base64url decoding

Write codeMedium15 min

Your task

Implement base64url decoding (the inverse of JWT-style encoding). Given a base64url string s that has had its '=' padding stripped, restore the padding, decode it, and return the original UTF-8 string. The input uses the URL-safe alphabet ('-' and '_'). An empty input decodes to an empty string. Assume the input is well-formed.

Examples

base64url_decode(s: str) -> str
Example 1
Inputbase64url_decode("aGVsbG8")
Output"hello"