mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 07:30:05 +08:00
Ship folder-based workspaces and data migration, daily practice, redesigned provider and model settings, and streaming conversation improvements. Synchronize README translations and document the archive/permanent-delete upgrade behavior in assets/releases/ver1-6-9.md. Reduce initial JavaScript by deduplicating English resources and loading animation features after hydration. Keep the existing route size budgets. Update regression fixtures and browser audits for scoped URLs and the new settings and learning interfaces.
21 lines
699 B
Python
21 lines
699 B
Python
"""Rebind persisted local download URLs while preserving resource identifiers."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from urllib.parse import parse_qsl, urlencode, urlsplit, urlunsplit
|
|
|
|
_LOCAL_URL = re.compile(
|
|
r"(?<![A-Za-z0-9:/])/(?:files/(?:attachments|outputs|workspace-items)/|api/(?:reading|video-learning)/)[^\s\"'<>\\)\]]+"
|
|
)
|
|
|
|
|
|
def rebind_local_urls(text: str, workspace_id: str) -> str:
|
|
def replace(match):
|
|
parts = urlsplit(match.group(0))
|
|
query = dict(parse_qsl(parts.query, keep_blank_values=True))
|
|
query["dt_workspace"] = workspace_id
|
|
return urlunsplit(parts._replace(query=urlencode(query)))
|
|
|
|
return _LOCAL_URL.sub(replace, text)
|