Repository: webpack/enhanced-resolve (js)

Issue:
AliasFieldPlugin.apply + lodash: resolving the wrong toString
When resolving `"./toString"` from `lodash`, [data2 on AliasFieldPlugin.js](https://github.com/webpack/enhanced-resolve/blob/c0797bbcb5d46a44930887c49dc5378b5527cd7a/lib/AliasFieldPlugin.js#L30) is removing the `./` from `"./toString"` of `lodash`, causing `fieldData` to get the default function `toString()` of every object.

Resulting in:
```shell
       var idxQuery = identifier.indexOf("?");
                                  ^

TypeError: identifier.indexOf is not a function
    at Resolver.parse (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:181:28)
    at Resolver.<anonymous> (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/ParsePlugin.js:17:25)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/tapable/lib/Tapable.js:256:13)
    at runNormal (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:130:20)
    at Resolver.doResolve (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:116:3)
    at Resolver.<anonymous> (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:37:12)
    at Resolver.applyPluginsAsyncSeriesBailResult1 (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/tapable/lib/Tapable.js:256:13)
    at runNormal (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:130:20)
    at Resolver.doResolve (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/Resolver.js:116:3)
    at Resolver.<anonymous> (/Users/fcconstantino/Projects/@products/@crefisa/NetBankApp/node_modules/enhanced-resolve/lib/AliasFieldPlugin.js:49:12)
```

Something I couldn't find is: Who is calling the `AliasFieldPlugin`?

A simple and easy fix was to do something like this:
```javascript
if (typeof data === 'function') {
    return callback();
}
```

**OBS:** I'm also using [Haul](https://github.com/callstack/haul), which uses an older version of `webpack`, but still the latest version of `enhanced-resolve`

| Using        | Version           |
| ------------- |-------------|
| npm     | 5.4.2 |
| webpack      | 2.7.0      | 
| enhanced-resolve | 3.4.1   |
| lodash      | 4.17.4      | 
| haul   | 1.0.0-beta.5   |


Pull request description:
use only alias field properties
prevent checking object prototype properties

fixes #118 

Patch:
diff --git a/lib/AliasFieldPlugin.js b/lib/AliasFieldPlugin.js
index 4699431..b7c79e2 100644
--- a/lib/AliasFieldPlugin.js
+++ b/lib/AliasFieldPlugin.js
@@ -49,9 +49,14 @@ module.exports = class AliasFieldPlugin {
 						);
 					return callback();
 				}
-				const data1 = fieldData[innerRequest];
-				const data2 = fieldData[innerRequest.replace(/^\.\//, "")];
-				const data = typeof data1 !== "undefined" ? data1 : data2;
+				const data = Object.prototype.hasOwnProperty.call(
+					fieldData,
+					innerRequest
+				)
+					? fieldData[innerRequest]
+					: innerRequest.startsWith("./")
+					? fieldData[innerRequest.slice(2)]
+					: undefined;
 				if (data === innerRequest) return callback();
 				if (data === undefined) return callback();
 				if (data === false) {


Test patch:
diff --git a/test/browserField.js b/test/browserField.js
index 4a31f42..95cbf9d 100644
--- a/test/browserField.js
+++ b/test/browserField.js
@@ -84,4 +84,10 @@ describe("browserField", function () {
 			.resolveSync({}, p(), "./lib/main2.js")
 			.should.be.eql(p("lib", "browser.js"));
 	});
+
+	it("should check only alias field properties", () => {
+		resolver
+			.resolveSync({}, p(), "./toString")
+			.should.be.eql(p("lib", "toString.js"));
+	});
 });
diff --git a/test/fixtures/browser-module/lib/toString.js b/test/fixtures/browser-module/lib/toString.js
new file mode 100644
index 0000000..e69de29
diff --git a/test/fixtures/browser-module/package.json b/test/fixtures/browser-module/package.json
index 8e4cbc7..217e0a9 100644
--- a/test/fixtures/browser-module/package.json
+++ b/test/fixtures/browser-module/package.json
@@ -4,6 +4,7 @@
     "./lib/replaced.js": "./lib/browser",
     "module-a": "./browser/module-a.js",
     "module-b": "module-c",
+    "./toString": "./lib/toString.js",
     ".": false
   },
   "innerBrowser1": {