Skip to content

Commit 912a2bf

Browse files
authored
Merge pull request #1475 from dhoizner/fix_file_link_resolution
Fix File Link Resolution
2 parents 84b120e + b4363d0 commit 912a2bf

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Diff for: client/modules/IDE/components/PreviewFrame.jsx

+7-4
Original file line numberDiff line numberDiff line change
@@ -249,16 +249,18 @@ class PreviewFrame extends React.Component {
249249
jsFileStrings.forEach((jsFileString) => {
250250
if (jsFileString.match(MEDIA_FILE_QUOTED_REGEX)) {
251251
const filePath = jsFileString.substr(1, jsFileString.length - 2);
252+
const quoteCharacter = jsFileString.substr(0, 1);
252253
const resolvedFile = resolvePathToFile(filePath, files);
254+
253255
if (resolvedFile) {
254256
if (resolvedFile.url) {
255-
newContent = newContent.replace(filePath, resolvedFile.url);
257+
newContent = newContent.replace(jsFileString, quoteCharacter + resolvedFile.url + quoteCharacter);
256258
} else if (resolvedFile.name.match(PLAINTEXT_FILE_REGEX)) {
257259
// could also pull file from API instead of using bloburl
258260
const blobURL = getBlobUrl(resolvedFile);
259261
this.props.setBlobUrl(resolvedFile, blobURL);
260-
const filePathRegex = new RegExp(filePath, 'gi');
261-
newContent = newContent.replace(filePathRegex, blobURL);
262+
263+
newContent = newContent.replace(jsFileString, quoteCharacter + blobURL + quoteCharacter);
262264
}
263265
}
264266
}
@@ -274,10 +276,11 @@ class PreviewFrame extends React.Component {
274276
cssFileStrings.forEach((cssFileString) => {
275277
if (cssFileString.match(MEDIA_FILE_QUOTED_REGEX)) {
276278
const filePath = cssFileString.substr(1, cssFileString.length - 2);
279+
const quoteCharacter = cssFileString.substr(0, 1);
277280
const resolvedFile = resolvePathToFile(filePath, files);
278281
if (resolvedFile) {
279282
if (resolvedFile.url) {
280-
newContent = newContent.replace(filePath, resolvedFile.url);
283+
newContent = newContent.replace(cssFileString, quoteCharacter + resolvedFile.url + quoteCharacter);
281284
}
282285
}
283286
}

Diff for: developer_docs/installation.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ Note that this is optional, unless you are working on the part of the applicatio
6969
If your S3 bucket is in the US East (N Virginia) region (us-east-1), you'll
7070
need to set a custom URL base for it, because it does not follow the standard
7171
naming pattern as the rest of the regions. Instead, add the following to your
72-
environment/.env file:
73-
74-
`S3_BUCKET_URL_BASE=https://s3.amazonaws.com`
72+
environment/.env file, changing `BUCKET_NAME` to your bucket name. This is necessary because this override is currently treated as the full path to the bucket rather than as a proper base url:
73+
`S3_BUCKET_URL_BASE=https://s3.amazonaws.com/{BUCKET_NAME}/`
7574

7675
If you've configured your S3 bucket and DNS records to use a custom domain
7776
name, you can also set it using this variable. I.e.:

0 commit comments

Comments
 (0)