mirror of
https://github.com/huhu/rust-search-extension
synced 2024-11-15 08:07:08 +00:00
16 lines
No EOL
441 B
JavaScript
16 lines
No EOL
441 B
JavaScript
function Deminifier(mapping) {
|
|
this.mapping = mapping;
|
|
}
|
|
|
|
Deminifier.prototype.deminify = function(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];
|
|
});
|
|
};
|
|
|
|
Deminifier.prototype.setMapping = function(mapping) {
|
|
this.mapping = mapping;
|
|
}; |