Skip to content

Commit

Permalink
things: use replaceAll when trimming authors
Browse files Browse the repository at this point in the history
We were using just `#replace`, which gives us some bad results which
were easily fixed via `#replaceAll`.

Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
mssola committed Mar 21, 2024
1 parent 819f299 commit e2f65c0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/javascript/controllers/thing_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ export default class extends Controller {
if (idx > -1) {
let idx2 = author.indexOf('_', idx + 1);
if (idx2 > -1) {
return author.substring(idx + 1, idx2).replace(' ', '');
return author.substring(idx + 1, idx2).replaceAll(' ', '');
}
}

// There was no pair of underscores, let's proceed by picking on the last
// name.
return author
.split(' ').pop().trim() // Pick the last element.
.replace('-', ''); // "Last-Other" => "LastOther"
.replaceAll('-', ''); // "Last-Other" => "LastOther"
}

// Update the information we get from the year field so to autocomplete it
Expand Down

0 comments on commit e2f65c0

Please sign in to comment.