Skip to content

Commit

Permalink
Ensure to trim whitespaces. Closes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko committed Oct 24, 2014
1 parent 752172e commit 3d7c188
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"bluebird": "2.3.x",
"csv": "0.3.7",
"csv": "0.3.x",
"jszip": "2.4.0",
"optimist": "0.6.1",
"underscore": "1.7.0",
Expand Down
8 changes: 4 additions & 4 deletions src/coffee/product-type-generator.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ class ProductTypeGenerator
attributeDefinition['inputHint'] = row['textInputHint']
when ATTRIBUTE_TYPES.enum
type['values'] = (type['values'] or []).concat [
key: row['enumKey']
label: row["#{ATTRIBUTE_TYPES.enum}Label"]
key: row['enumKey'].trim()

This comment has been minimized.

Copy link
@butenkor

butenkor Oct 24, 2014

Member

should not you check if row value exists? row['enumKey']?.trim()

This comment has been minimized.

Copy link
@hajoeichler

hajoeichler Oct 24, 2014

Member

This is done by the API.
We should not double the validation in the client.

This comment has been minimized.

Copy link
@butenkor

butenkor Oct 24, 2014

Member

But before you get it send to api you may get here uncaught TypeError or ReferenceError

This comment has been minimized.

Copy link
@emmenko

emmenko Oct 24, 2014

Author Member

This tool does not use the API, it just transforms CSV --> JSON.

@butenkor hmm a null check would be better yes
@hajoeichler is that what you mean with this issue #13 ? I'm having second thoughts now that I did it wrong... :(

label: row["#{ATTRIBUTE_TYPES.enum}Label"].trim()
]
when ATTRIBUTE_TYPES.lenum
type['values'] = (type['values'] or []).concat [
key: row['enumKey']
key: row['enumKey'].trim()
label: @_i18n row, "#{ATTRIBUTE_TYPES.enum}Label"
]
when ATTRIBUTE_TYPES.set
Expand Down Expand Up @@ -182,7 +182,7 @@ class ProductTypeGenerator
i18n = {}
languages = @_languages header, _.keys row
for language in languages
i18n[language] = row["#{header}.#{language}"]
i18n[language] = row["#{header}.#{language}"].trim()
i18n

###*
Expand Down
2 changes: 1 addition & 1 deletion src/coffee/run.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Reads a CSV file by given path and returns a promise for the result.
###
readCsvAsync = (path) ->
new Promise (resolve, reject) ->
Csv().from.path(path, {columns: true})
Csv().from.path(path, {columns: true, trim: true})
.to.array (data, count) -> resolve data
.on 'error', (error) -> reject error

Expand Down

0 comments on commit 3d7c188

Please sign in to comment.