Skip to content

Commit 6071df1

Browse files
committed
Prevent the use of '/' with no value.
1 parent df0d7c1 commit 6071df1

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

web_src/js/features/repo-editor.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export function initRepoEditor() {
8181
let containSpace = false;
8282
for (let i = 0; i < parts.length; ++i) {
8383
const value = parts[i];
84-
if (value.trim() === '..') {
84+
const trimValue = value.trim();
85+
if (trimValue === '..') {
8586
// remove previous tree path
8687
if (links.length > 0) {
8788
links[links.length - 1].remove();
@@ -90,15 +91,15 @@ export function initRepoEditor() {
9091
continue;
9192
}
9293
if (i < parts.length - 1) {
93-
if (value.length) {
94+
if (trimValue.length) {
9495
$(`<span class="section"><a href="#">${htmlEscape(value)}</a></span>`).insertBefore($(filenameInput));
9596
$('<div class="breadcrumb-divider">/</div>').insertBefore($(filenameInput));
9697
}
9798
} else {
9899
filenameInput.value = value;
99100
}
100101
this.setSelectionRange(0, 0);
101-
containSpace |= value.trim() !== value;
102+
containSpace |= (trimValue !== value && trimValue !== '');
102103
}
103104
let warningDiv = document.querySelector('.ui.warning.message.flash-message.flash-warning.space-related');
104105
containSpace |= Array.from(links).some((link) => {

0 commit comments

Comments
 (0)