mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
avoid exception in validateProjectName
This commit is contained in:
parent
3d2f9f0219
commit
8cf3288187
2 changed files with 7 additions and 1 deletions
|
@ -57,7 +57,7 @@ module.exports = ProjectDetailsHandler =
|
|||
|
||||
MAX_PROJECT_NAME_LENGTH: 150
|
||||
validateProjectName: (name, callback = (error) ->) ->
|
||||
if name.length == 0
|
||||
if !name? or name.length == 0
|
||||
return callback(new Errors.InvalidNameError("Project name cannot be blank"))
|
||||
else if name.length > @MAX_PROJECT_NAME_LENGTH
|
||||
return callback(new Errors.InvalidNameError("Project name is too long"))
|
||||
|
|
|
@ -126,6 +126,12 @@ describe 'ProjectDetailsHandler', ->
|
|||
done()
|
||||
|
||||
describe "validateProjectName", ->
|
||||
|
||||
it "should reject undefined names", (done) ->
|
||||
@handler.validateProjectName undefined, (error) ->
|
||||
expect(error).to.exist
|
||||
done()
|
||||
|
||||
it "should reject empty names", (done) ->
|
||||
@handler.validateProjectName "", (error) ->
|
||||
expect(error).to.exist
|
||||
|
|
Loading…
Reference in a new issue