@nina-protocol/nina-db 0.0.35 → 0.0.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -109,7 +109,14 @@ export default class Release extends Model {
109
109
  if (string.length > 200) {
110
110
  string = string.substring(0, 200);
111
111
  }
112
- const slug = string.toLowerCase().replace('-', '').replace(/ +/g, ' ').replace(/ /g, '-').replace(/[^a-z0-9-]/g, '');
112
+ const slug = string
113
+ .normalize('NFKD').replace(/[\u0300-\u036F]/g, '') // remove accents and convert to closest ascii equivalent
114
+ .toLowerCase() // convert to lowercase
115
+ .replace('-', '') // remove hyphens
116
+ .replace(/ +/g, ' ') // remove spaces
117
+ .replace(/ /g, '-') // replace spaces with hyphens
118
+ .replace(/[^a-zA-Z0-9-]/g, '') // remove non-alphanumeric characters
119
+ .replace(/--+/g, ''); // remove spaces
113
120
  const existingRelease = await Release.query().findOne({ slug });
114
121
  if (existingRelease) {
115
122
  return `${slug}-${randomStringGenerator()}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.35",
3
+ "version": "0.0.37",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -120,7 +120,14 @@ export default class Release extends Model {
120
120
  if (string.length > 200) {
121
121
  string = string.substring(0, 200);
122
122
  }
123
- const slug = string.toLowerCase().replace('-', '').replace(/ +/g, ' ').replace(/ /g, '-').replace(/[^a-z0-9-]/g, '');
123
+ const slug = string
124
+ .normalize('NFKD').replace(/[\u0300-\u036F]/g, '') // remove accents and convert to closest ascii equivalent
125
+ .toLowerCase() // convert to lowercase
126
+ .replace('-', '') // remove hyphens
127
+ .replace(/ +/g, ' ') // remove spaces
128
+ .replace(/ /g, '-') // replace spaces with hyphens
129
+ .replace(/[^a-zA-Z0-9-]/g, '') // remove non-alphanumeric characters
130
+ .replace(/--+/g, '') // remove spaces
124
131
  const existingRelease = await Release.query().findOne({ slug });
125
132
  if (existingRelease) {
126
133
  return `${slug}-${randomStringGenerator()}`;