|
2 | 2 | import datetime |
3 | 3 | import logging |
4 | 4 | import os |
5 | | -import urllib.parse |
| 5 | +from urllib.parse import urljoin |
6 | 6 | from pathlib import Path |
7 | 7 |
|
8 | 8 | import ics |
@@ -408,12 +408,6 @@ def get_relative_url(current, target): |
408 | 408 | return rel |
409 | 409 |
|
410 | 410 |
|
411 | | -def get_absolute_url(current, target): |
412 | | - """Get absolute url from the ``target``, which is relative to ``current``. |
413 | | - """ |
414 | | - return urllib.parse.urljoin(current, target) |
415 | | - |
416 | | - |
417 | 411 | def relative_url_functions(current_url, course, lesson): |
418 | 412 | """Return relative URL generators based on current page. |
419 | 413 | """ |
@@ -489,7 +483,7 @@ def content_creator(): |
489 | 483 | # The urls are added twice to ``absolute_urls_to_freeze`` |
490 | 484 | # when the content is created. |
491 | 485 | # But it doesn't matter, duplicate URLs are skipped. |
492 | | - absolute_urls = [get_absolute_url(request.path, x) for x in cached["urls"]] |
| 486 | + absolute_urls = [urljoin(request.path, x) for x in cached["urls"]] |
493 | 487 | absolute_urls_to_freeze.extend(absolute_urls) |
494 | 488 |
|
495 | 489 | return cached |
@@ -538,12 +532,12 @@ def course_page(course, lesson, page, solution=None): |
538 | 532 | if content is None: |
539 | 533 | # the offer was accepted |
540 | 534 | content = content_offer["content"] |
541 | | - absolute_urls_to_freeze.extend([get_absolute_url(request.path, x) |
| 535 | + absolute_urls_to_freeze.extend([urljoin(request.path, x) |
542 | 536 | for x in content_offer["urls"]]) |
543 | 537 | else: |
544 | 538 | # the offer was rejected or the the fragment was not in cache |
545 | 539 | arca.region.set(content_key, {"content": content, "urls": data_from_fork["content_urls"]}) |
546 | | - absolute_urls_to_freeze.extend([get_absolute_url(request.path, x) |
| 540 | + absolute_urls_to_freeze.extend([urljoin(request.path, x) |
547 | 541 | for x in data_from_fork["content_urls"]]) |
548 | 542 |
|
549 | 543 | # compatibility |
|
0 commit comments