Skip to content

Commit d0324c2

Browse files
authored
fix: remove shares prefix from blob uploads (#2866)
1 parent 78f59e3 commit d0324c2

3 files changed

Lines changed: 3 additions & 6 deletions

File tree

playground/blob-upload.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import {SHARE_PATH_PREFIX} from './src/utility/helpers/blob-upload.js';
2-
31
export const MAX_SHARE_FILE_SIZE_BYTES = 1024 * 1024;
42
export const SHARE_ALLOWED_CONTENT_TYPES = [
53
'text/yaml',
@@ -11,7 +9,7 @@ export const SHARE_ALLOWED_CONTENT_TYPES = [
119
];
1210

1311
function isValidSharePathname(pathname) {
14-
return new RegExp(`^${SHARE_PATH_PREFIX}[A-Za-z0-9-]+\\.ya?ml$`).test(pathname);
12+
return /^[A-Za-z0-9-]+\.ya?ml$/.test(pathname);
1513
}
1614

1715
function getHeader(request, name) {

playground/src/layout/main-layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import yaml from "js-yaml";
77
import {useShapeStore} from "@state/shape";
88
import Share from "@components/modals/share";
99
import toast, {Toaster} from 'react-hot-toast';
10-
import {BLOB_UPLOAD_ROUTE, SHARE_PATH_PREFIX} from "@utility/helpers/blob-upload";
10+
import {BLOB_UPLOAD_ROUTE} from "@utility/helpers/blob-upload";
1111

1212
const {Option, OptGroup} = Select;
1313
const {Content} = Layout;
@@ -64,7 +64,7 @@ const MainLayout = ({children, ...rest}) => {
6464
const uniqueId = `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
6565
const fileName = `${uniqueId}.yaml`;
6666
const file = new File([yamlString], fileName, {type: 'text/x-yaml'});
67-
upload(`${SHARE_PATH_PREFIX}${fileName}`, file, {
67+
upload(fileName, file, {
6868
access: 'public',
6969
handleUploadUrl: BLOB_UPLOAD_ROUTE,
7070
}).then((result) => {
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export const BLOB_UPLOAD_ROUTE = '/api/blob/upload';
2-
export const SHARE_PATH_PREFIX = 'shares/';

0 commit comments

Comments
 (0)