Files
DeepTutor/deeptutor/services/workspace/references.py
Bingxi Zhao (Frank) da856ad670 release: v1.6.9
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.
2026-09-21 02:30:40 +08:00

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)