Build and Push Docker Container / build-and-push (push) Successful in 2m25s
- Require Python 3.15 for the server and Python 3.14 for the CLI. - Match the server requirement to quart_common's Python 3.15 features. - Replace future annotations with native deferred evaluation. - Defer CLI command dependencies and QR imports on Python 3.15. - Enable argparse suggestions for mistyped CLI commands. - Remove the obsolete tomllib import fallback. - Update my_helpers and quart_common submodule references. - Lock test dependencies and exclude them from Docker installations. - Add regression coverage for lazy imports and deferred annotations. - Document runtime requirements and standalone CLI validation. - Validate 276 tests on Python 3.15 and 18 CLI tests on Python 3.14. BREAKING CHANGE: The server now requires Python 3.15+ and the standalone CLI requires Python 3.14+.
34 lines
876 B
Python
34 lines
876 B
Python
from urllib.parse import urlsplit
|
|
|
|
_ALLOWED_SCHEMES = {'http', 'https'}
|
|
|
|
def _normalize_host(host: str) -> str:
|
|
return (host or '').split(',')[0].strip().lower().rstrip('.')
|
|
|
|
def parse_share_link(url: str, host: str, root_path: str = '') -> str | None:
|
|
"""Return the file_id when url points at this instance's /-<file_id> route."""
|
|
try:
|
|
parts = urlsplit(url)
|
|
except ValueError:
|
|
return None
|
|
|
|
if parts.scheme.lower() not in _ALLOWED_SCHEMES:
|
|
return None
|
|
if not parts.netloc or _normalize_host(parts.netloc) != _normalize_host(host):
|
|
return None
|
|
|
|
prefix = (root_path or '').rstrip('/')
|
|
path = parts.path
|
|
if prefix:
|
|
if not path.startswith(prefix + '/'):
|
|
return None
|
|
path = path[len(prefix):]
|
|
|
|
if not path.startswith('/-'):
|
|
return None
|
|
|
|
file_id = path[2:]
|
|
if not file_id or '/' in file_id:
|
|
return None
|
|
return file_id
|