push
github
1384 of 2717 branches covered (50.94%)
2 of 50 new or added lines in 5 files covered. (4.0%)
13868 of 74230 relevant lines covered (18.68%)
1.87 hits per line
1 |
import { useCallback } from 'react'; |
|
2 |
import { useEnv } from './useEnv'; |
× |
3 |
|
× |
NEW
|
function pathJoin(...parts: string[]) {
|
× |
NEW
|
const separator = '/'; |
× |
NEW
|
const replace = new RegExp(separator + '+', 'g'); |
× |
NEW
|
return parts.join(separator).replace(replace, separator);
|
× |
NEW
|
} |
× |
NEW
|
|
× |
10 |
export const usePreviewUrl = () => { |
× |
11 |
const { storagePrefix } = useEnv();
|
× |
12 |
|
× |
13 |
return useCallback(
|
× |
NEW
|
(path: string) => {
|
× |
NEW
|
if (!storagePrefix) {
|
× |
NEW
|
console.error('storagePrefix is not set'); |
× |
NEW
|
return path;
|
× |
NEW
|
} |
× |
NEW
|
return pathJoin(storagePrefix, path);
|
× |
20 |
}, |
× |
21 |
[storagePrefix] |
× |
22 |
); |
× |
23 |
}; |
× |