Skip to content

Commit

Permalink
Accept Windows installations on other drives than C: (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahuggins-nhs committed Apr 23, 2020
1 parent d6d02f5 commit 2161745
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/hosts-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {stat, readFile} = require('fs').promises;
const {isIP} = require('net');

const isWindows = process.platform === 'win32';
const hostsPath = isWindows ? 'C:\\Windows\\System32\\drivers\\etc\\hosts' : '/etc/hosts';
const hostsPath = isWindows ? `${process.env.SystemDrive}\\Windows\\System32\\drivers\\etc\\hosts` : '/etc/hosts';

const hostnameRegExp = /^(?:(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9])\.)*(?:[A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9-]*[A-Za-z0-9])$/;
const isHostname = hostname => hostnameRegExp.test(hostname);
Expand Down

0 comments on commit 2161745

Please sign in to comment.