Просмотр исходного кода

Trim the project name again after fixing (#15682)

GitOrigin-RevId: 74c87ee1689668a058a162a1f456815e0748b049
Alf Eaton 2 лет назад
Родитель
Сommit
b0effa7e4a

+ 2 - 0
services/web/app/src/Features/Project/ProjectDetailsHandler.js

@@ -193,6 +193,8 @@ function fixProjectName(name) {
   if (name.length > MAX_PROJECT_NAME_LENGTH) {
     name = name.substr(0, MAX_PROJECT_NAME_LENGTH)
   }
+  // Remove any leading or trailing whitespace after fixing
+  name = name.trim()
   return name
 }
 

+ 6 - 0
services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js

@@ -439,6 +439,12 @@ describe('ProjectDetailsHandler', function () {
     it('should accept normal names', function () {
       expect(this.handler.fixProjectName('foobar')).to.equal('foobar')
     })
+
+    it('should trim name after truncation', function () {
+      expect(this.handler.fixProjectName('a'.repeat(149) + ' a')).to.equal(
+        'a'.repeat(149)
+      )
+    })
   })
 
   describe('setPublicAccessLevel', function () {