fixes for relative paths

This commit is contained in:
zadam 2019-02-22 23:03:20 +01:00
parent cf5ec44303
commit b25deea21d
7 changed files with 8 additions and 7 deletions

View File

@ -26,7 +26,7 @@ async function show() {
$fileSize.text((attributeMap.fileSize || "?") + " bytes"); $fileSize.text((attributeMap.fileSize || "?") + " bytes");
$fileType.text(currentNote.mime); $fileType.text(currentNote.mime);
$imageView.prop("src", `/api/images/${currentNote.noteId}/${currentNote.title}`); $imageView.prop("src", `api/images/${currentNote.noteId}/${currentNote.title}`);
} }
$imageDownloadButton.click(() => utils.download(getFileUrl())); $imageDownloadButton.click(() => utils.download(getFileUrl()));

View File

@ -122,7 +122,7 @@ async function renderTooltip(note, attributes) {
} }
else if (note.type === 'image') { else if (note.type === 'image') {
content += $("<img>") content += $("<img>")
.prop("src", `/api/images/${note.noteId}/${note.title}`) .prop("src", `api/images/${note.noteId}/${note.title}`)
.prop('outerHTML'); .prop('outerHTML');
} }
// other types of notes don't have tooltip preview // other types of notes don't have tooltip preview

View File

@ -91,7 +91,7 @@ function SetupModel() {
} }
// not using server.js because it loads too many dependencies // not using server.js because it loads too many dependencies
const resp = await $.post('/api/setup/sync-from-server', { const resp = await $.post('api/setup/sync-from-server', {
syncServerHost: syncServerHost, syncServerHost: syncServerHost,
syncProxy: syncProxy, syncProxy: syncProxy,
username: username, username: username,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -43,7 +43,7 @@ async function saveImage(buffer, originalName, parentNoteId) {
return { return {
fileName, fileName,
noteId: note.noteId, noteId: note.noteId,
url: `/api/images/${note.noteId}/${fileName}` url: `api/images/${note.noteId}/${fileName}`
}; };
} }

View File

@ -207,7 +207,8 @@ function findImageLinks(content, foundLinks) {
} }
// removing absolute references to server to keep it working between instances // removing absolute references to server to keep it working between instances
return content.replace(/src="[^"]*\/api\/images\//g, 'src="/api/images/'); // we also omit / at the beginning to keep the paths relative
return content.replace(/src="[^"]*\/api\/images\//g, 'src="api/images/');
} }
function findHyperLinks(content, foundLinks) { function findHyperLinks(content, foundLinks) {