diff --git a/services/web/app/src/Features/Project/ProjectDetailsHandler.js b/services/web/app/src/Features/Project/ProjectDetailsHandler.js index ad89efe7d5..0509ea5982 100644 --- a/services/web/app/src/Features/Project/ProjectDetailsHandler.js +++ b/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 } diff --git a/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js b/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js index d11626f6e7..235fec66cb 100644 --- a/services/web/test/unit/src/Project/ProjectDetailsHandlerTests.js +++ b/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 () {