

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Uniform Resource Identifiers
incomplete
2: Sections of a URL
incomplete
3: Further Dissecting a URL
incomplete
4: The Protocol
incomplete
5: URL Ports
incomplete
6: URL Paths
incomplete
7: Query Parameters
incomplete
This lesson's interactive features are locked, please to keep using them
URLs have quite a few sections. Some are required, some are not.
Let's use the url.URL struct again. This time, we'll parse a URL string and add all the different parts to a custom ParsedURL struct. We'll learn more about each part later.
Complete the newParsedURL function. It should return a ParsedURL with all the parts of a URL. For example, given this URL:
http://testuser:testpass@testdomain.com:8080/testpath?testsearch=testvalue#testhash
newParsedURL should return a struct with these fields:
return ParsedURL{
protocol: "http",
username: "testuser",
password: "testpass",
hostname: "testdomain.com",
port: "8080",
pathname: "/testpath",
search: "testsearch=testvalue",
hash: "testhash",
}
Use these fields and methods of the URL struct:
SchemeUser.Username()User.Password() - this method returns two values: the password if set and whether it was setHostname()Port()PathRawQueryFragment