mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 12:15:50 +00:00
WebSocket Tool: Fix slug formula (allow _) to fix 'Try It' links
This commit is contained in:
@@ -16,13 +16,13 @@ function slugify(str) {
|
|||||||
str = str.toLowerCase()
|
str = str.toLowerCase()
|
||||||
|
|
||||||
// remove accents, swap ñ for n, etc
|
// remove accents, swap ñ for n, etc
|
||||||
const from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;"
|
const from = "àáäâèéëêìíïîòóöôùúüûñç·/,:;"
|
||||||
const to = "aaaaeeeeiiiioooouuuunc------"
|
const to = "aaaaeeeeiiiioooouuuunc-----"
|
||||||
for (let i=0, l=from.length ; i<l ; i++) {
|
for (let i=0, l=from.length ; i<l ; i++) {
|
||||||
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i))
|
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i))
|
||||||
}
|
}
|
||||||
|
|
||||||
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
|
str = str.replace(/[^a-z0-9 _-]/g, '') // remove invalid chars
|
||||||
.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
||||||
.replace(/-+/g, '-'); // collapse dashes
|
.replace(/-+/g, '-'); // collapse dashes
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user