2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-12-22 18:18:55 +00:00

Remove non ascii chars from filename

Non-ascii characters cause weird wine errors when building for win32 on darwin

```
$ nativefier stackedit.io ~/Desktop -o -p win32
```

Stack trace:
```
fixme:heap:RtlSetHeapInformation 0x0 1 0x0 0 stub
Fatal error: Unable to load file
```
This commit is contained in:
Jia Hao 2016-03-09 13:51:22 +08:00
parent 34039baefd
commit ac2260c395

View File

@ -2,7 +2,7 @@ import os from 'os';
import path from 'path';
import _ from 'lodash';
import async from 'async';
import sanitizeFilename from 'sanitize-filename';
import sanitizeFilenameLib from 'sanitize-filename';
import inferIcon from './../infer/inferIcon';
import inferTitle from './../infer/inferTitle';
@ -98,9 +98,14 @@ function optionsFactory(inpOptions, callback) {
});
}
function sanitizeFilename(str) {
const cleaned = sanitizeFilenameLib(str);
// remove non ascii
return cleaned.replace(/[^\x00-\x7F]/, '');
}
function sanitizeOptions(options) {
options.name = sanitizeFilename(options.name);
return options;
}