Skip to content

Commit 95ea965

Browse files
committed
Fix creation of diagrams in root directory
1 parent c526b21 commit 95ea965

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

script.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ jQuery(function () {
6363
appendTo: '.dokuwiki',
6464
modal: true,
6565
open: function () {
66-
const ns = isMMPage ? jQuery('.panelHeader h3 strong').text() : jQuery('#media__ns').text();
66+
const nsText = isMMPage ? jQuery('.panelHeader h3 strong').text() : jQuery('#media__ns').text();
67+
const ns = cleanNs(nsText);
6768
jQuery('#diagrams__current-ns').text(ns);
6869
},
6970
close: function () {

script/helpers.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ function validId(id) {
1111
return id.length > 0 && /^[\w][\w\.\-]*$/.test(id)
1212
}
1313

14+
/**
15+
* Media Manager encloses the root dir in [] so let's strip that
16+
* because it is not a real namespace
17+
*/
18+
function cleanNs (text) {
19+
return text.replace(/^\[.*\]$/, '');
20+
}
21+
1422
/**
1523
* return URL of an existing diagram
1624
*

0 commit comments

Comments
 (0)