@samitouri / QOSami-HFS / commits / 1318eb64

fix: problems if folder name contains # inside breadcrumb #293

Massimo Melina committed Jul 19, 2023 at 12:05 UTC 1318eb64f25200fc608877f9a4059c1435f8735b
3 files changed +4 -4
frontend/src/Breadcrumbs.ts
+1 -1
@@ -40,7 +40,7 @@ function Breadcrumb({ path, label, current }:{ current?: boolean, path: string,
40 if (!current) return
41 if (typeof label !== 'string')
42 return reload()
43 - openFileMenu(new DirEntry(path), ev, [
43 + openFileMenu(new DirEntry(decodeURIComponent(path)), ev, [
44 {
45 label: t`Reload`,
46 icon: 'reload',
frontend/src/fileMenu.ts
+2 -2
@@ -3,7 +3,7 @@ import { dontBotherWithKeys, formatBytes, hfsEvent, hIcon, newDialog, prefix, wi
3 import { createElement as h, Fragment, isValidElement, MouseEventHandler, MouseEvent, ReactNode } from 'react'
4 import _ from 'lodash'
5 import { getEntryIcon, MISSING_PERM } from './BrowseFiles'
6 -import { DirEntry, state } from './state'
6 +import { DirEntry, pathEncode, state } from './state'
7 import { deleteFiles } from './menu'
8 import { Link } from 'react-router-dom'
9 import { fileShow, getShowType } from './show'
@@ -117,7 +117,7 @@ async function rename(entry: DirEntry) {
117 }
118 alertDialog(t`Operation successful`).then(() => {
119 if (isCurrentFolder)
120 - navigate(uri + '../' + dest + '/')
120 + navigate(uri + '../' + pathEncode(dest) + '/')
121 })
122 }
123 catch(e: any) {
frontend/src/state.ts
+1 -1
@@ -132,7 +132,7 @@ export class DirEntry {
132 }
133 export type DirList = DirEntry[]
134
135 -function pathEncode(s: string) {
135 +export function pathEncode(s: string) {
136 return encodeURI(s).replace(/#/g, encodeURIComponent)
137 }
138 //unused function pathDecode(s: string) { return decodeURI(s).replace(/%23/g, '#') }