mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-28 17:23:28 -04:00
Update:Experimental RSS feed setting custom slugs with default to library item id #553
This commit is contained in:
parent
55c40658f2
commit
195a30096f
5 changed files with 112 additions and 41 deletions
|
@ -125,6 +125,31 @@ Vue.prototype.$sanitizeFilename = (input, replacement = '') => {
|
|||
return sanitized
|
||||
}
|
||||
|
||||
// SOURCE: https://gist.github.com/spyesx/561b1d65d4afb595f295
|
||||
// modified: allowed underscores
|
||||
Vue.prototype.$sanitizeSlug = (str) => {
|
||||
if (!str) return ''
|
||||
|
||||
str = str.replace(/^\s+|\s+$/g, '') // trim
|
||||
str = str.toLowerCase()
|
||||
|
||||
// remove accents, swap ñ for n, etc
|
||||
var from = "àáäâèéëêìíïîòóöôùúüûñçěščřžýúůďťň·/,:;"
|
||||
var to = "aaaaeeeeiiiioooouuuuncescrzyuudtn-----"
|
||||
|
||||
for (var i = 0, l = from.length; i < l; i++) {
|
||||
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i))
|
||||
}
|
||||
|
||||
str = str.replace('.', '-') // replace a dot by a dash
|
||||
.replace(/[^a-z0-9 -_]/g, '') // remove invalid chars
|
||||
.replace(/\s+/g, '-') // collapse whitespace and replace by a dash
|
||||
.replace(/-+/g, '-') // collapse dashes
|
||||
.replace(/\//g, '') // collapse all forward-slashes
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
Vue.prototype.$copyToClipboard = (str, ctx) => {
|
||||
return new Promise((resolve) => {
|
||||
if (!navigator.clipboard) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue