export const PORTABLE_DATA_HASH_PATTERN = '[a-f0-9]{32}\\+\\d+';
export const RESOURCE_UUID_REGEX = new RegExp("^" + RESOURCE_UUID_PATTERN + "$");
export const COLLECTION_PDH_REGEX = new RegExp("^" + PORTABLE_DATA_HASH_PATTERN + "$");
+export const KEEP_URL_REGEX = new RegExp("^(keep:)?" + PORTABLE_DATA_HASH_PATTERN);
export const isResourceUuid = (uuid: string) =>
RESOURCE_UUID_REGEX.test(uuid);
import { navigateTo } from 'store/navigation/navigation-action';
import classNames from 'classnames';
import { DefaultCodeSnippet } from 'components/default-code-snippet/default-code-snippet';
+import { KEEP_URL_REGEX } from 'models/resource';
type CssRules =
| "card"
return basename ? (mime.getType(basename) || "").startsWith('image/') : false;
};
+const isFileUrl = (location?: string): boolean => (
+ !!location && !KEEP_URL_REGEX.exec(location) &&
+ (location.startsWith("http://") || location.startsWith("https://"))
+);
+
const normalizeDirectoryLocation = (directory: Directory): Directory => {
if (!directory.location) {
return directory;
const fileToProcessIOValue = (file: File, secondary: boolean, auth: AuthState, pdh: string | undefined, mainFilePdh: string): ProcessIOValue => {
if (isExternalValue(file)) {return {display: <UnsupportedValue />}}
+ if (isFileUrl(file.location)) {
+ return {
+ display: <MuiLink href={file.location} target="_blank">{file.location}</MuiLink>,
+ secondary,
+ };
+ }
+
const resourcePdh = getResourcePdhUrl(file, pdh);
return {
display: <KeepUrlPath auth={auth} res={file} pdh={pdh}/>,