Makes a given link absolute.
(self, link)
| 304 | return set(gen()) |
| 305 | |
| 306 | def _make_absolute(self, link): |
| 307 | """Makes a given link absolute.""" |
| 308 | |
| 309 | # Parse the link with stdlib. |
| 310 | parsed = urlparse(link)._asdict() |
| 311 | |
| 312 | # If link is relative, then join it with base_url. |
| 313 | if not parsed['netloc']: |
| 314 | return urljoin(self.base_url, link) |
| 315 | |
| 316 | # Link is absolute; if it lacks a scheme, add one from base_url. |
| 317 | if not parsed['scheme']: |
| 318 | parsed['scheme'] = urlparse(self.base_url).scheme |
| 319 | |
| 320 | # Reconstruct the URL to incorporate the new scheme. |
| 321 | parsed = (v for v in parsed.values()) |
| 322 | return urlunparse(parsed) |
| 323 | |
| 324 | # Link is absolute and complete with scheme; nothing to be done here. |
| 325 | return link |
| 326 | |
| 327 | |
| 328 | @property |