fix: admin/shared: unnecessary encoding of links with emoji
Massimo Melina committed
Feb 9, 2025 at 11:41 UTC
213a0849bdc8cf1e6e70ed9c5c95b4ea593742c8
2 files changed
+4
-4
admin/src/VfsPage.ts
+2
-2
@@ -5,7 +5,7 @@ import { apiCall, useApiEx } from './api'
5
import { Alert, Box, Button, Card, CardContent, Grid, Link, List, ListItem, ListItemText, Typography } from '@mui/material'
6
import { state, useSnapState } from './state'
7
import VfsTree, { vfsNodeIcon } from './VfsTree'
8
-import { CFG, matches, newDialog, normalizeHost, onlyTruthy, prefix, VfsNodeAdminSend } from './misc'
8
+import { CFG, matches, newDialog, normalizeHost, onlyTruthy, pathEncode, prefix, VfsNodeAdminSend } from './misc'
9
import { Flex, useBreakpoint } from './mui'
10
import { reactJoin } from '@hfs/shared'
11
import _ from 'lodash'
@@ -140,7 +140,7 @@ export default function VfsPage({ setTitleSide }: PageProps) {
140
// calculate id and parent fields, and builds the map id2node
141
function recur(node: VfsNode, pre='/', parent: VfsNode|undefined=undefined) {
142
node.parent = parent
143
- node.id = node.isRoot ? '/' : prefix(pre, encodeURIComponent(node.name), node.type === 'folder' ? '/' : '')
143
+ node.id = node.isRoot ? '/' : prefix(pre, pathEncode(node.name), node.type === 'folder' ? '/' : '')
144
id2node.set(node.id, node)
145
if (!node.children) return
146
for (const n of node.children)
frontend/src/upload.ts
+2
-2
@@ -4,7 +4,7 @@ import { createElement as h, DragEvent, Fragment, useMemo, useState, useEffect,
4
import { Btn, Flex, FlexV, iconBtn, Select } from './components'
5
import {
6
basename, formatBytes, formatPerc, hIcon, useIsMobile, newDialog, selectFiles, working, copyTextToClipboard,
7
- HTTP_CONFLICT, formatSpeed, getHFS, onlyTruthy, cpuSpeedIndex, closeDialog, prefix, operationSuccessful,
7
+ HTTP_CONFLICT, formatSpeed, getHFS, onlyTruthy, cpuSpeedIndex, closeDialog, prefix, operationSuccessful, pathEncode,
8
} from './misc'
9
import _ from 'lodash'
10
import { INTERNAL_Snapshot, ref, useSnapshot } from 'valtio'
@@ -276,7 +276,7 @@ export async function createFolder() {
276
await alertDialog(h(() =>
277
h(FlexV, {},
278
h('div', {}, t`Successfully created`),
279
- h(LinkClosingDialog, { to: uri + encodeURIComponent(name) + '/' }, t('enter_folder', "Enter the folder")),
279
+ h(LinkClosingDialog, { to: uri + pathEncode(name) + '/' }, t('enter_folder', "Enter the folder")),
280
)))
281
}
282
catch(e: any) {