Skip to content

Commit

Permalink
fix-onPaste-Keyvalue
Browse files Browse the repository at this point in the history
  • Loading branch information
skanakal committed Jan 12, 2025
1 parent 938b866 commit 4a7f8dd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions shell/components/form/KeyValue.vue
Original file line number Diff line number Diff line change
Expand Up @@ -521,9 +521,15 @@ export default {
const text = event.clipboardData.getData('text/plain');
const lines = text.split('\n');
const splits = lines.map((line) => {
const splitter = this.parserSeparators.find((sep) => line.includes(sep));
const separatorIndex = line.search(new RegExp(this.parserSeparators.join('|')));
return splitter ? line.split(splitter) : '';
if (separatorIndex === -1) {
return null;
}
const key = line.substring(0, separatorIndex).trim();
const value = line.substring(separatorIndex + 1).trim();
return [key, value];
}).filter((split) => split && split.length > 0);
if (splits.length === 0 || (splits.length === 1 && splits[0].length < 2)) {
Expand Down

0 comments on commit 4a7f8dd

Please sign in to comment.