|
1 | 1 | import { SUPPORTED_FILES, DA_ORIGIN } from '../../../shared/constants.js'; |
| 2 | +import { sanitizePath, sanitizePathParts } from '../../../../scripts/utils.js'; |
2 | 3 | import { daFetch } from '../../../shared/utils.js'; |
3 | 4 |
|
4 | 5 | const MAX_DEPTH = 1000; |
@@ -81,12 +82,6 @@ export async function getFullEntryList(entries) { |
81 | 82 | return files.filter((file) => file); |
82 | 83 | } |
83 | 84 |
|
84 | | -export function sanitizePath(path) { |
85 | | - const pathArray = path.split('/'); |
86 | | - const sanitizedArray = pathArray.map((element) => element.replaceAll(/[^a-zA-Z0-9.]/g, '-').toLowerCase()); |
87 | | - return [...sanitizedArray].join('/'); |
88 | | -} |
89 | | - |
90 | 85 | export async function handleUpload(list, fullpath, file) { |
91 | 86 | const { data, path } = file; |
92 | 87 | const formData = new FormData(); |
@@ -122,8 +117,7 @@ export async function handleUpload(list, fullpath, file) { |
122 | 117 | export function items2Clipboard(items) { |
123 | 118 | const aemUrls = items.reduce((acc, item) => { |
124 | 119 | if (item.ext) { |
125 | | - const path = item.path.replace('.html', ''); |
126 | | - const [org, repo, ...pathParts] = path.substring(1).split('/'); |
| 120 | + const [org, repo, ...pathParts] = sanitizePathParts(item.path.replace('.html', '')); |
127 | 121 | const pageName = pathParts.pop(); |
128 | 122 | pathParts.push(pageName === 'index' ? '' : pageName); |
129 | 123 |
|
|
0 commit comments