Permalink
Browse files

Throw error if layer names start with a number

  • Loading branch information...
Koen Bok
Koen Bok committed Dec 16, 2015
1 parent 864d7d5 commit b4583d4d5eed5939edcfbabe8a6c8627d0a45d5d
Showing with 6 additions and 1 deletion.
  1. +6 −1 framer/Importer.coffee
View
@@ -27,7 +27,8 @@ getScaleFromName = (str) ->
return null
startsWithNumber = (str) ->
return (new RegExp("^[0-9]")).test(str)
class exports.Importer
@@ -123,6 +124,10 @@ class exports.Importer
else if superLayer
layerInfo.superLayer = superLayer
# Layer names cannot start with a number
if startsWithNumber(layerInfo.name)
throw new Error("(#{layerInfo.name}) Layer or Artboard names can not start with a number")
# Sanitize the layer names so mylayer.jpg gets converted to mylayer
for suffix in [".jpg", ".pdf"]
layerInfo.name = layerInfo.name.replace(suffix, "") if _.endsWith(layerInfo.name, suffix)

0 comments on commit b4583d4

Please sign in to comment.