mirror of
https://github.com/PeWu/topola-viewer.git
synced 2025-12-23 18:50:04 +00:00
Handle links shared from Google Drive
This commit is contained in:
parent
a78a8aca66
commit
f588c62696
@ -45,6 +45,16 @@ export async function loadFromUrl(
|
||||
} catch (e) {
|
||||
console.warn('Failed to load data from session storage: ' + e);
|
||||
}
|
||||
|
||||
const driveUrlMatch1 = url.match(/https:\/\/drive\.google\.com\/file\/d\/(.*)\/.*/);
|
||||
if (driveUrlMatch1) {
|
||||
url = `https://drive.google.com/uc?id=${driveUrlMatch1[1]}&export=download`;
|
||||
}
|
||||
const driveUrlMatch2 = url.match(/https:\/\/drive\.google\.com\/open\?id=([^&]*)&?.*/);
|
||||
if (driveUrlMatch2) {
|
||||
url = `https://drive.google.com/uc?id=${driveUrlMatch2[1]}&export=download`;
|
||||
}
|
||||
|
||||
const urlToFetch = handleCors
|
||||
? 'https://cors-anywhere.herokuapp.com/' + url
|
||||
: url;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user