Skip to content

Commit

Permalink
Merge pull request #27 from Arzte/Fix-regex
Browse files Browse the repository at this point in the history
Fix regex to properly import codes, irregardless of source
  • Loading branch information
ltouroumov committed Aug 19, 2024
2 parents 45bc535 + f388f45 commit 1221e55
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions components/viewer/modal/BackpackModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
</div>
<div class="pack-import-export">
<strong>Import / Export</strong>
<textarea v-model="importCode" class="import-code form-control" />
<textarea
v-model="importCode"
class="import-code form-control"
placeholder="Will delete all selected items if empty!!"
/>
<button
class="import-btn btn btn-outline-primary"
@click="readImportCode"
Expand Down Expand Up @@ -159,11 +163,16 @@ function copyExportText() {
}, 4000);
}
const LEGACY_RX = /^(\w+(\/ON#\d+)?)(,(\w+(\/ON#\d+)?))*$/;
const LEGACY_RX =
/^(?:[a-zA-Z0-9-]+(?:\/ON#\d+)?)(?:,[a-zA-Z0-9-]+(?:\/ON#\d+)?)*$/;
function readImportCode() {
const _code = importCode.value?.trim();
console.log(`Import Code ${_code}`);
if (!_code) return;
if (!_code) {
console.log(`No import code provided. Clearing Selections...`);
selected.value = {};
return;
}
const selections: Selections = {};
if (LEGACY_RX.test(_code)) {
Expand Down

0 comments on commit 1221e55

Please sign in to comment.