test: cover nextcloud proxy url handling
This commit is contained in:
1 parent
f061dd2f38
commit
ee753331ce
3 files changed
+65
-3
No files matched your search
@@ -1,6 +1,6 @@
|
||||
import type { ServerResponse } from "node:http";
|
||||
|
||||
function parseHttpUrl(value: string, errorMessage: string): URL {
|
||||
export function parseHttpUrl(value: string, errorMessage: string): URL {
|
||||
const url = new URL(value.trim());
|
||||
|
||||
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
||||
@@ -14,7 +14,7 @@ function parseHttpUrl(value: string, errorMessage: string): URL {
|
||||
return url;
|
||||
}
|
||||
|
||||
function resolveDavUrlFromShareUrl(shareUrl: string): string {
|
||||
export function resolveDavUrlFromShareUrl(shareUrl: string): string {
|
||||
const url = parseHttpUrl(shareUrl, "Please enter a public Nextcloud share link.");
|
||||
const publicShare = url.pathname.match(/\/s\/([^/?#]+)/);
|
||||
|
||||
@@ -31,7 +31,7 @@ function resolveDavUrlFromShareUrl(shareUrl: string): string {
|
||||
throw new Error("Please enter a public Nextcloud share link.");
|
||||
}
|
||||
|
||||
function resolveValidatedBlobUrl(targetUrl: string, shareUrl: string): string {
|
||||
export function resolveValidatedBlobUrl(targetUrl: string, shareUrl: string): string {
|
||||
const target = parseHttpUrl(targetUrl, "Invalid image URL.");
|
||||
const shareDavUrl = new URL(resolveDavUrlFromShareUrl(shareUrl));
|
||||
|
||||
|
||||
Reference in new issue
Block a user