Browse Source

refactor: should not remove the model suffix

e22m4u 1 week ago
parent
commit
94af4c66e0

+ 0 - 2
dist/cjs/index.cjs

@@ -398,8 +398,6 @@ function modelNameToModelKey(modelName) {
       "The model name should be a non-empty String without spaces, but %v was given.",
       modelName
     );
-  if (modelName.toLowerCase() !== "model")
-    modelName = modelName.replace(/[-_]?Model$/, "").replace(/[-_](MODEL|model)$/, "");
   return modelName.toLowerCase().replace(/[-_]/g, "");
 }
 var init_model_name_to_model_key = __esm({

+ 0 - 4
src/utils/model-name-to-model-key.js

@@ -13,9 +13,5 @@ export function modelNameToModelKey(modelName) {
         'without spaces, but %v was given.',
       modelName,
     );
-  if (modelName.toLowerCase() !== 'model')
-    modelName = modelName
-      .replace(/[-_]?Model$/, '')
-      .replace(/[-_](MODEL|model)$/, '');
   return modelName.toLowerCase().replace(/[-_]/g, '');
 }

+ 0 - 23
src/utils/model-name-to-model-key.spec.js

@@ -36,29 +36,6 @@ describe('modelNameToModelKey', function () {
     expect(modelNameToModelKey(modelName)).to.be.eq(expected);
   });
 
-  it('should remove the "model" word from a model name', function () {
-    const modelNames = [
-      'userProfileDetailsModel',
-      'UserProfileDetailsModel',
-      'user-profile-details-model',
-      'user_profile_details_model',
-      'User-Profile-Details-Model',
-      'User_Profile_Details_Model',
-      'USER-PROFILE-DETAILS-MODEL',
-      'USER_PROFILE_DETAILS_MODEL',
-    ];
-    modelNames.forEach(v =>
-      expect(modelNameToModelKey(v)).to.be.eq('userprofiledetails'),
-    );
-  });
-
-  it('should not remove the "model" suffix as a part of last word in a model name', function () {
-    const exceptions = ['SUPERMODEL', 'supermodel'];
-    exceptions.forEach(v =>
-      expect(modelNameToModelKey(v)).to.be.eq('supermodel'),
-    );
-  });
-
   it('should throw an error for an empty string', function () {
     const throwable = () => modelNameToModelKey('');
     expect(throwable).to.throw(