Skip to content

Usenet streaming with a WebDAV server and a SABnzbd-compatible API

C#

Fixed urls with special characters (#90)

nzbdav-dev5dc60ca86243
diff --git a/frontend/app/routes/explore/route.tsx b/frontend/app/routes/explore/route.tsx
index 57130a6a..26e2801c 100644
--- a/frontend/app/routes/explore/route.tsx
+++ b/frontend/app/routes/explore/route.tsx
@@ -25,7 +25,7 @@ export async function loader({ request }: Route.LoaderArgs) {
if (request.url.endsWith('/')) return redirect(request.url.slice(0, -1));
// load items from backend
- let path = getWebdavPath(new URL(request.url).pathname);
+ let path = getWebdavPathDecoded(new URL(request.url).pathname);
return {
parentDirectories: getParentDirectories(path),
items: (await backendClient.listWebdavDirectory(path)).map(x => {
@@ -52,16 +52,16 @@ function Body(props: ExplorePageData) {
const items = props.items;
const parentDirectories = isNavigating
- ? getParentDirectories(getWebdavPath(navigation.location!.pathname))
+ ? getParentDirectories(getWebdavPathDecoded(navigation.location!.pathname))
: props.parentDirectories;
const getDirectoryPath = useCallback((directoryName: string) => {
- return `${location.pathname}/${directoryName}`
+ return `${location.pathname}/${encodeURIComponent(directoryName)}`;
}, [location.pathname]);
const getFilePath = useCallback((file: ExploreFile) => {
var pathname = getWebdavPath(location.pathname);
- return `/view/${pathname}/${file.name}?downloadKey=${file.downloadKey}`;
+ return `/view/${pathname}/${encodeURIComponent(file.name)}?downloadKey=${file.downloadKey}`;
}, [location.pathname]);
return (
@@ -99,13 +99,16 @@ function getIcon(file: ExploreFile) {
}
function getWebdavPath(pathname: string): string {
- pathname = decodeURIComponent(pathname);
if (pathname.startsWith("/")) pathname = pathname.slice(1);
if (pathname.startsWith("explore")) pathname = pathname.slice(7);
if (pathname.startsWith("/")) pathname = pathname.slice(1);
return pathname;
}
+function getWebdavPathDecoded(pathname: string): string {
+ return decodeURIComponent(getWebdavPath(pathname));
+}
+
function getParentDirectories(webdavPath: string): string[] {
return webdavPath == "" ? [] : webdavPath.split('/');
}
diff --git a/frontend/app/routes/queue/components/history-table/history-table.tsx b/frontend/app/routes/queue/components/history-table/history-table.tsx
index e6a71962..48ebfee3 100644
--- a/frontend/app/routes/queue/components/history-table/history-table.tsx
+++ b/frontend/app/routes/queue/components/history-table/history-table.tsx
@@ -153,13 +153,19 @@ export function HistoryRow({ slot, onIsSelectedChanged, onIsRemovingChanged, onR
}
export function Actions({ slot, onRemove }: { slot: PresentationHistorySlot, onRemove: () => void }) {
+ // determine explore action link url
var downloadFolder = slot.storage && getLeafDirectoryName(slot.storage);
+ const encodedCategory = downloadFolder && encodeURIComponent(slot.category);
+ const encodedDownloadFolder = downloadFolder && encodeURIComponent(downloadFolder);
+ var folderLink = downloadFolder && `/explore/content/${encodedCategory}/${encodedDownloadFolder}`;
+
+ // determine whether explore action should be disabled
var isFolderDisabled = !downloadFolder || !!slot.isRemoving || !!slot.fail_message;
return (
<>
{!isFolderDisabled &&
- <Link to={`/explore/content/${slot.category}/${downloadFolder}`} >
+ <Link to={folderLink} >
<ActionButton type="explore" />
</Link>
}