Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ proto.getSource = function (name) {
this.pathsToNames[fullpath] = name;
var content = fs.readFileSync(fullpath);
debug('view %s mapping to %s, charset: %s, size: %d', name, fullpath, charset, content.length);
if (charset && (charset !== 'utf8' || charset !== 'utf-8')) {
if (charset && charset !== 'utf8' && charset !== 'utf-8') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还是有点别扭,建议 if 分支顺序换下。

if (!charset || charset === 'utf-8' || charset === 'utf8') {
  content = content.toString();
} else {
  content = iconv.decode(content, charset);
}

content = iconv.decode(content, charset);
} else {
content = content.toString();
Expand Down