mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Adding google drive plugin as a fallback for url plugin
Summary: When importing from url, user types a url for google spreadsheet, Grist will switch to Google Drive plugin to allow user to choose file manualy. Test Plan: Browser tests Reviewers: paulfitz, dsagal Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2945
This commit is contained in:
@@ -154,6 +154,12 @@ export async function uploadFiles(
|
||||
export async function fetchURL(
|
||||
docComm: DocComm, url: string, onProgress: ProgressCB = noop
|
||||
): Promise<UploadResult> {
|
||||
|
||||
if (isDriveUrl(url)) {
|
||||
// don't download from google drive, immediately fallback to server side.
|
||||
return docComm.fetchURL(url);
|
||||
}
|
||||
|
||||
let response: Response;
|
||||
try {
|
||||
response = await window.fetch(url);
|
||||
@@ -173,6 +179,12 @@ export async function fetchURL(
|
||||
return res!;
|
||||
}
|
||||
|
||||
export function isDriveUrl(url: string) {
|
||||
if (!url) { return null; }
|
||||
const match = /^https:\/\/(docs|drive).google.com\/(spreadsheets|file)\/d\/([^/]*)/i.exec(url);
|
||||
return !!match;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a form to a JSON-stringifiable object, ignoring any File fields.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user