summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2020-04-20 11:32:44 +0100
committerGitHub <noreply@github.com>2020-04-20 13:32:44 +0300
commit067eff8ebaaf7b05ef8514bc051c72f1f80ddc82 (patch)
tree09685b866290c4eb88c37660ef1f296ede691c3d /web_src
parentda3e85a502d18271801ab0ae3c568cc8b6dfe7ca (diff)
downloadgitea-067eff8ebaaf7b05ef8514bc051c72f1f80ddc82.tar.gz
gitea-067eff8ebaaf7b05ef8514bc051c72f1f80ddc82.zip
Ensure that relative paths in edit preview work (#11143)
Fix #10131 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/index.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/web_src/js/index.js b/web_src/js/index.js
index 2bf34a956d..ed747765a0 100644
--- a/web_src/js/index.js
+++ b/web_src/js/index.js
@@ -64,10 +64,16 @@ function initEditPreviewTab($form) {
previewFileModes = $previewTab.data('preview-file-modes').split(',');
$previewTab.on('click', function () {
const $this = $(this);
+ let context = `{$this.data('context')}/`;
+ const treePathEl = $form.find('input#tree_path');
+ if (treePathEl.length > 0) {
+ context += treePathEl.val();
+ }
+ context = context.substring(0, context.lastIndexOf('/'));
$.post($this.data('url'), {
_csrf: csrf,
mode: 'gfm',
- context: $this.data('context'),
+ context,
text: $form.find(`.tab.segment[data-tab="${$tabMenu.data('write')}"] textarea`).val()
}, (data) => {
const $previewPanel = $form.find(`.tab.segment[data-tab="${$tabMenu.data('preview')}"]`);