Skip to content

Commit

Permalink
fix: no need to encode path
Browse files Browse the repository at this point in the history
  • Loading branch information
yongenaelf committed Nov 19, 2024
1 parent 19f4317 commit ecb8a04
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions components/file-explorer/delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ export default function Delete({
onClick={async () => {
if (type === "file") {
await db.files.delete(
`${pathname}/${encodeURIComponent(path)}`
`${pathname}/${path}`
);
} else {
const all = (
await db.files
.filter((file) =>
file.path.startsWith(
`${pathname}/${encodeURIComponent(path + "/")}`
`${pathname}/${path}/`
)
)
.toArray()
Expand Down
4 changes: 2 additions & 2 deletions components/file-explorer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ const FileExplorer = () => {

if (e.key === "Enter") {
await db.files.add({
path: `${pathname}/${encodeURIComponent(
path: `${pathname}/${
`${state.path}/${e.currentTarget.value}${
state.addType === "folder" ? "/.gitkeep" : ""
}`
)}`,
}`,
contents: "",
});
await refreshFileExplorer();
Expand Down
2 changes: 1 addition & 1 deletion components/file-explorer/new-file-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function NewFileForm({
form.clearErrors();
try {
await db.files.add({
path: `${pathname}/${encodeURIComponent(data.path)}`,
path: `${pathname}/${data.path}`,
contents: "",
});
await refreshFileExplorer();
Expand Down
8 changes: 4 additions & 4 deletions components/file-explorer/rename-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,22 @@ export function RenameForm({

try {
if (type === "file") {
const currentKey = `${pathname}/${encodeURIComponent(path)}`;
const currentKey = `${pathname}/${path}`;
const currentFile = await db.files.get(currentKey);

const newKey = `${pathname}/${encodeURIComponent(data.path)}`;
const newKey = `${pathname}/${data.path}`;
await db.files.add({
path: newKey,
contents: currentFile?.contents || "",
});
await db.files.delete(currentKey);
} else {
const currentKey = `${pathname}/${encodeURIComponent(path)}`;
const currentKey = `${pathname}/${path}`;
const currentFiles = await db.files
.filter((file) => file.path.startsWith(currentKey))
.toArray();

const newKey = `${pathname}/${encodeURIComponent(data.path)}`;
const newKey = `${pathname}/${data.path}`;
const newFiles = currentFiles.map((i) => ({
...i,
path: i.path.replace(currentKey, newKey),
Expand Down
2 changes: 1 addition & 1 deletion components/github/repo-workspace-name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function RepoWorkspaceName({

await db.files.bulkAdd(
response.map(({ path, contents }) => ({
path: `/workspace/${data.name}/${encodeURIComponent(rootPath ? path.replace(rootPath + "/", "") : path)}`,
path: `/workspace/${data.name}/${rootPath ? path.replace(rootPath + "/", "") : path}`,
contents,
}))
);
Expand Down
2 changes: 1 addition & 1 deletion components/new-workspace-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function WorkspaceForm() {

await db.files.bulkAdd(
templateData.map(({ path, contents }) => ({
path: `/workspace/${data.name}/${encodeURIComponent(path)}`,
path: `/workspace/${data.name}/${path}`,
contents,
}))
);
Expand Down
2 changes: 1 addition & 1 deletion components/tutorial/generate-template-solidity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function GenerateTemplateSolidity({

const templateData: { path: string; contents: string }[] = [
{
path: encodeURIComponent("src/HelloWorld.sol"),
path: "src/HelloWorld.sol",
contents: `// SPDX-License-Identifier: MIT
// compiler version must be greater than or equal to 0.8.24 and less than 0.9.0
pragma solidity ^0.8.24;
Expand Down
2 changes: 1 addition & 1 deletion components/tutorial/generate-template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function GenerateTemplate({
);
await db.files.bulkAdd(
templateData.map(({ path, contents }) => ({
path: `${pathname}/${encodeURIComponent(path)}`,
path: `${pathname}/${path}`,
contents,
}))
);
Expand Down
2 changes: 1 addition & 1 deletion components/workspace/file-upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function FileUpload() {

await db.files.bulkAdd(
templateData.map(({ path, contents }) => ({
path: `/workspace/${name}/${encodeURIComponent(path)}`,
path: `/workspace/${name}/${path}`,
contents,
}))
);
Expand Down
2 changes: 1 addition & 1 deletion components/workspace/upload-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function UploadModal() {

await db.files.bulkAdd(
templateData.map(({ path, contents }) => ({
path: `${pathname}/${encodeURIComponent(path)}`,
path: `${pathname}/${path}`,
contents,
}))
);
Expand Down
2 changes: 1 addition & 1 deletion src/routes/share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function Component() {

await db.files.bulkAdd(
data.files.map(({ path, contents }) => ({
path: `/workspace/${id}/${encodeURIComponent(path)}`,
path: `/workspace/${id}/${path}`,
contents,
}))
);
Expand Down

0 comments on commit ecb8a04

Please sign in to comment.