Compare commits
2 Commits
c28e4874d9
...
3d8d74785c
| Author | SHA1 | Date | |
|---|---|---|---|
|
3d8d74785c
|
|||
|
1c58de68b6
|
+1
-1
Submodule my_helpers updated: 7bb10e4ea0...28795d2b18
+1
-1
Submodule quart_common updated: be555d897e...235ba7b8e9
+8
-2
@@ -24,6 +24,12 @@ def find_file(files: list[dict], file_id: str):
|
||||
return file_data
|
||||
return None
|
||||
|
||||
def build_share_url(file_id: str) -> str:
|
||||
scheme = (request.headers.get("X-Forwarded-Proto") or request.scheme or "http").split(",")[0].strip()
|
||||
host = (request.headers.get("X-Forwarded-Host") or request.host).split(",")[0].strip()
|
||||
root_path = request.root_path.rstrip("/")
|
||||
return f"{scheme}://{host}{root_path}/-{file_id}"
|
||||
|
||||
@side_main_bp.route('/')
|
||||
@LIMITER.limit("10 per minute;50 per hour")
|
||||
async def index():
|
||||
@@ -54,7 +60,7 @@ async def file_info(file_id, user):
|
||||
abort(404)
|
||||
|
||||
access_data = await current_app.convex.get_file_access(file_id=file_id, user_id=user["sub"]) or []
|
||||
share_url = request.url_root.rstrip("/") + f"/-{file_id}"
|
||||
share_url = build_share_url(file_id)
|
||||
return await render_template(
|
||||
"views/webpage/files/info.htm",
|
||||
file=file_data,
|
||||
@@ -69,7 +75,7 @@ async def file_edit(file_id, user):
|
||||
if not file_data:
|
||||
abort(404)
|
||||
|
||||
share_url = request.url_root.rstrip("/") + f"/-{file_id}"
|
||||
share_url = build_share_url(file_id)
|
||||
return await render_template(
|
||||
"views/webpage/files/edit.htm", file=file_data, share_url=share_url, file_id=file_id
|
||||
)
|
||||
|
||||
@@ -143,7 +143,14 @@
|
||||
const previewBody = document.getElementById('previewBody');
|
||||
if (!previewBody) return;
|
||||
|
||||
const url = '{{ share_url }}';
|
||||
let url = '{{ share_url }}';
|
||||
if (window.location.protocol === 'https:' && url.startsWith('http://')) {
|
||||
const parsed = new URL(url);
|
||||
if (parsed.host === window.location.host) {
|
||||
parsed.protocol = 'https:';
|
||||
url = parsed.toString();
|
||||
}
|
||||
}
|
||||
try {
|
||||
const response = await fetch(url, { method: 'GET' });
|
||||
if (!response.ok) {
|
||||
|
||||
Reference in New Issue
Block a user