mirror of
https://github.com/strapi/strapi.git
synced 2025-07-18 22:45:47 +00:00

* add possibility to use strapi on a non-root base url path * fix documentation password form * use server.url and admin.url in config Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * update doc proxy Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * move server.url location in config Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * refacto Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * add possibility to put relative urls Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * allow '/' as an admin url + refacto Signed-off-by: Pierre Noël <pierre.noel@strapi.io> * update yarn.lock Signed-off-by: Pierre Noël <petersg83@gmail.com> * refacto Signed-off-by: Pierre Noël <petersg83@gmail.com> * Remove default proxy option Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com> * fix github provider Signed-off-by: Pierre Noël <petersg83@gmail.com> * fix github login Signed-off-by: Pierre Noël <petersg83@gmail.com> * Remove files that should be here Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com> Co-authored-by: Pierre Noël <pierre.noel@strapi.io> Co-authored-by: Alexandre Bodin <bodin.alex@gmail.com>
41 lines
873 B
JavaScript
41 lines
873 B
JavaScript
'use strict';
|
|
|
|
const slugify = require('@sindresorhus/slugify');
|
|
|
|
const nameToSlug = name => slugify(name, { separator: '-' });
|
|
|
|
const nameToCollectionName = name => slugify(name, { separator: '_' });
|
|
|
|
const getCommonBeginning = (str1 = '', str2 = '') => {
|
|
let common = '';
|
|
let index = 0;
|
|
while (index < str1.length && index < str2.length) {
|
|
if (str1[index] === str2[index]) {
|
|
common += str1[index];
|
|
index += 1;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
return common;
|
|
};
|
|
|
|
const escapeQuery = (query, charsToEscape, escapeChar = '\\') => {
|
|
return query
|
|
.split('')
|
|
.reduce(
|
|
(escapedQuery, char) =>
|
|
charsToEscape.includes(char)
|
|
? `${escapedQuery}${escapeChar}${char}`
|
|
: `${escapedQuery}${char}`,
|
|
''
|
|
);
|
|
};
|
|
|
|
module.exports = {
|
|
nameToSlug,
|
|
nameToCollectionName,
|
|
getCommonBeginning,
|
|
escapeQuery,
|
|
};
|