@nina-protocol/nina-db 0.0.34 → 0.0.36

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.
@@ -105,7 +105,17 @@ export default class Release extends Model {
105
105
  }
106
106
  };
107
107
  static generateSlug = async (metadata) => {
108
- const slug = metadata.name.toLowerCase().replace(/ /g, '-').replace(/[^a-z0-9-]/g, '');
108
+ let string = metadata.name;
109
+ if (string.length > 200) {
110
+ string = string.substring(0, 200);
111
+ }
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(/![^\W_0-9-]/g, ''); // remove non-alphanumeric characters
109
119
  const existingRelease = await Release.query().findOne({ slug });
110
120
  if (existingRelease) {
111
121
  return `${slug}-${randomStringGenerator()}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
@@ -116,7 +116,18 @@ export default class Release extends Model {
116
116
  }
117
117
 
118
118
  static generateSlug = async (metadata) => {
119
- const slug = metadata.name.toLowerCase().replace(/ /g, '-').replace(/[^a-z0-9-]/g, '');
119
+ let string = metadata.name
120
+ if (string.length > 200) {
121
+ string = string.substring(0, 200);
122
+ }
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(/![^\W_0-9-]/g, ''); // remove non-alphanumeric characters
130
+
120
131
  const existingRelease = await Release.query().findOne({ slug });
121
132
  if (existingRelease) {
122
133
  return `${slug}-${randomStringGenerator()}`;