Generating and using URL slugs for releases, improver slugify module. Added 'extract' parameter to MindGeek scraper to get scenes not associate with a channel (see Digital Playground). Added various high res logos.

This commit is contained in:
2020-02-04 03:12:09 +01:00
parent ca33704f51
commit f921bb4ae9
30 changed files with 132 additions and 22 deletions

View File

@@ -1,7 +1,21 @@
'use strict';
function slugify(string, encode = false, delimiter = '-') {
const slug = string.trim().toLowerCase().match(/\w+/g).join(delimiter);
function slugify(string, {
encode = false,
delimiter = '-',
limit = 1000,
} = {}) {
const slugComponents = string.trim().toLowerCase().match(/\w+/g);
const slug = slugComponents.reduce((acc, component, index) => {
const accSlug = `${acc}${index > 0 ? delimiter : ''}${component}`;
if (accSlug.length < limit) {
return accSlug;
}
return acc;
}, '');
return encode ? encodeURI(slug) : slug;
}