mirror of
https://github.com/huhu/rust-search-extension
synced 2024-11-14 23:57:07 +00:00
18 lines
445 B
JavaScript
18 lines
445 B
JavaScript
class Deminifier {
|
|
constructor(mapping) {
|
|
this.mapping = mapping;
|
|
}
|
|
|
|
deminify(rawDescription) {
|
|
if (rawDescription === null) return null;
|
|
// Regex to globally, case-sensitively match words.
|
|
return rawDescription
|
|
.replace(/[@$^&][0-9a-zA-Z]/g, (value) => {
|
|
return this.mapping[value];
|
|
});
|
|
}
|
|
|
|
setMapping(mapping) {
|
|
this.mapping = mapping;
|
|
}
|
|
}
|