mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-09 17:49:03 +00: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:
parent
d8615ddba3
commit
9d8e682819
4 changed files with 733 additions and 697 deletions
|
@ -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(
|
||||
|
|
1409
services/web/package-lock.json
generated
1409
services/web/package-lock.json
generated
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",
|
||||
|
|
Loading…
Add table
Reference in a new issue