-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use path.extname instead of regex comparisons #31
Comments
Are we talking about this if block? Lines 339 to 353 in e82a402
|
Bah I wrote the wrong filename. It's here in config.js |
The general ideas being, make that one less place to require code maintenance when we add support for some future file type. |
Oh, ok I will fix it. |
If this is the purpose should I do something about this line too? Line 120 in e82a402
|
Hrmm, a string found there would be the user explicitly specifying the file content type. As you can see, some of the types (value, list, data) don't map to filename extensions. I don't know what you can do there that would improve it. |
Ok from this: Lines 131 to 137 in e82a402
I boiled it down to this: if (!fs_type) {
var fs_ext = path.extname(fs_name);
switch (fs_ext) {
case ".hjson":
case ".json":
case ".yaml":
case ".ini":
fs_type = fs_ext.substring(1);
break;
default:
fs_type = 'value';
break;
}
} Opinion? |
Almost perfect. You'll fail lint tests because of the |
Perl habits die hard, eh?
…On Fri, Sep 29, 2017 at 3:39 PM, Matt Simerson ***@***.***> wrote:
Almost perfect. You'll fail lint tests because of the var. Use const
instead. The other thing I'd do differently (not required) is consistently
use single quotes. They're easier to read and I'm in the habit of always
using ' unless I "*want*" interpolation.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAobY3wO--vp6zNb7b3n-tE8VB6_zejCks5snUdogaJpZM4PnvHL>
.
|
Ok, got it. I tend to use double quotes because they mean string where single quote usually means single character. But I will abide. |
LOL. Actually, sh/bash/POSIX, which predate my perl habits and which I still use very frequently. |
Interesting, in what context? |
Mainly C# and like. I am not sure but I think C and C++ also do this. Edit: I was correct, https://stackoverflow.com/a/3683613/1829884. |
Darn you! I've tried so hard to forget the |
I did one small change please take a look before I issue a PR. https://github.com/PSSGCSim/haraka-config/commit/bdaaa02a7e6db410151922d054251bd4c1304fa7 It is regarding where the |
Even better, getting rid of the redundant leading dots. 👍 |
In configfile, we have an if/else chain that inspects a filename to determine its type. Instead, we should likely use path.extname.
The text was updated successfully, but these errors were encountered: