mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 21:59:00 +02:00
Merge pull request #2767 from overleaf/spd-oio-moreurls
Add support for data urls and snip arrays to Open-in-Overleaf GitOrigin-RevId: 2c41406940b90c422cec8a823bf004fcc2655ed2
This commit is contained in:
committed by
Copybot
parent
d8615ddba3
commit
9d8e682819
@@ -1,5 +1,6 @@
|
||||
const Settings = require('settings-sharelatex')
|
||||
const { URL } = require('url')
|
||||
const isDataUrl = require('valid-data-url')
|
||||
|
||||
function getSafeRedirectPath(value) {
|
||||
const baseURL = Settings.siteUrl // base URL is required to construct URL from path
|
||||
@@ -14,6 +15,11 @@ function getSafeRedirectPath(value) {
|
||||
const UrlHelper = {
|
||||
getSafeRedirectPath,
|
||||
wrapUrlWithProxy(url) {
|
||||
// we already have the data for data URLs
|
||||
if (isDataUrl(url)) {
|
||||
return url
|
||||
}
|
||||
|
||||
// TODO: Consider what to do for Community and Enterprise edition?
|
||||
if (!Settings.apis.linkedUrlProxy.url) {
|
||||
throw new Error('no linked url proxy configured')
|
||||
@@ -22,7 +28,7 @@ const UrlHelper = {
|
||||
},
|
||||
|
||||
prependHttpIfNeeded(url) {
|
||||
if (!url.match('://')) {
|
||||
if (!url.match('://') && !isDataUrl(url)) {
|
||||
url = `http://${url}`
|
||||
}
|
||||
return url
|
||||
|
||||
@@ -16,6 +16,7 @@ const uuid = require('uuid')
|
||||
const _ = require('underscore')
|
||||
const Settings = require('settings-sharelatex')
|
||||
const request = require('request')
|
||||
const parseDataUrl = require('parse-data-url')
|
||||
const { promisifyAll } = require('../util/promises')
|
||||
|
||||
const FileWriter = {
|
||||
@@ -104,6 +105,16 @@ const FileWriter = {
|
||||
callback = function(error, fsPath) {}
|
||||
}
|
||||
callback = _.once(callback)
|
||||
|
||||
const dataUrl = parseDataUrl(url)
|
||||
if (dataUrl) {
|
||||
return FileWriter.writeContentToDisk(
|
||||
identifier,
|
||||
dataUrl.toBuffer(),
|
||||
callback
|
||||
)
|
||||
}
|
||||
|
||||
const stream = request.get(url)
|
||||
stream.on('error', function(err) {
|
||||
logger.warn(
|
||||
|
||||
Generated
+713
-696
File diff suppressed because it is too large
Load Diff
@@ -92,6 +92,7 @@
|
||||
"oauth2-server": "^3.0.1",
|
||||
"otplib": "^12.0.1",
|
||||
"p-limit": "^2.3.0",
|
||||
"parse-data-url": "^2.0.0",
|
||||
"passport": "^0.4.1",
|
||||
"passport-google-oauth20": "^2.0.0",
|
||||
"passport-local": "^1.0.0",
|
||||
@@ -117,6 +118,7 @@
|
||||
"url-parse": "^1.4.7",
|
||||
"utf-8-validate": "^5.0.2",
|
||||
"uuid": "^3.0.1",
|
||||
"valid-data-url": "^2.0.0",
|
||||
"valid-url": "^1.0.9",
|
||||
"xml2js": "^0.4.22",
|
||||
"xregexp": "^4.3.0",
|
||||
|
||||
Reference in New Issue
Block a user