mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 12:15:50 +00:00
15 lines
347 B
TypeScript
15 lines
347 B
TypeScript
/**
|
|
* Slugify function, has to match the formula used in interactive-tutorial.js
|
|
*/
|
|
export function slugify(s) {
|
|
const unacceptable_chars = /[^A-Za-z0-9._ ]+/g;
|
|
const whitespace_regex = /\s+/g;
|
|
s = s.replace(unacceptable_chars, '');
|
|
s = s.replace(whitespace_regex, '_');
|
|
s = s.toLowerCase();
|
|
if (!s) {
|
|
s = '_';
|
|
}
|
|
return s;
|
|
}
|