Repository: webpack/enhanced-resolve (js)

Issue:
About the new change in AliasPlugin.js
last week, your team update the version of the enhanced-resolve
however, using v5.9.2, my project cannot build at all, it will be stuck while building. 
It makes me really puzzled, because my project's alias is `'#': path.resolve(__dirname, './src'),`
when I change it into `'balabala': path.resolve(__dirname, './src'),`, it will continue to build. balabala can be anything but #
and when I change the line 47 into "request.path",  `'#': path.resolve(__dirname, './src'),` can also make it.
So I'm wondering the reason why your team make such a change



Pull request description:
fix hash aliases
fixes #334 

Patch:
diff --git a/lib/AliasPlugin.js b/lib/AliasPlugin.js
index ee42952..76f8dbb 100644
--- a/lib/AliasPlugin.js
+++ b/lib/AliasPlugin.js
@@ -6,6 +6,7 @@
 "use strict";
 
 const forEachBail = require("./forEachBail");
+const { PathType, getType } = require("./util/path");
 
 /** @typedef {import("./Resolver")} Resolver */
 /** @typedef {import("./Resolver").ResolveRequest} ResolveRequest */
@@ -30,6 +31,18 @@ module.exports = class AliasPlugin {
 	 */
 	apply(resolver) {
 		const target = resolver.ensureHook(this.target);
+		const getAbsolutePathWithSlashEnding = maybeAbsolutePath => {
+			const type = getType(maybeAbsolutePath);
+			if (type === PathType.AbsolutePosix || type === PathType.AbsoluteWin) {
+				return resolver.join(maybeAbsolutePath, "_").slice(0, -1);
+			}
+			return null;
+		};
+		const isSubPath = (path, maybeSubPath) => {
+			const absolutePath = getAbsolutePathWithSlashEnding(maybeSubPath);
+			if (!absolutePath) return false;
+			return path.startsWith(absolutePath);
+		};
 		resolver
 			.getHook(this.source)
 			.tapAsync("AliasPlugin", (request, resolveContext, callback) => {
@@ -42,11 +55,9 @@ module.exports = class AliasPlugin {
 						if (
 							innerRequest === item.name ||
 							(!item.onlyModule &&
-								innerRequest.startsWith(
-									request.request
-										? `${item.name}/`
-										: resolver.join(item.name, "_").slice(0, -1)
-								))
+								(request.request
+									? innerRequest.startsWith(`${item.name}/`)
+									: isSubPath(innerRequest, item.name)))
 						) {
 							const remainingRequest = innerRequest.substr(item.name.length);
 							const resolveWithAlias = (alias, callback) => {


Test patch:
diff --git a/test/alias.js b/test/alias.js
index 84479f0..a167294 100644
--- a/test/alias.js
+++ b/test/alias.js
@@ -39,6 +39,9 @@ describe("alias", function () {
 				recursive: "recursive/dir",
 				"/d/dir": "/c/dir",
 				"/d/index.js": "/c/index",
+				// alias configuration should work
+				"#": "/c/dir",
+				"@": "/c/dir",
 				ignored: false
 			},
 			modules: "/",
@@ -61,6 +64,14 @@ describe("alias", function () {
 			.resolveSync({}, "/", "aliasA/dir/index")
 			.should.be.eql("/a/dir/index");
 	});
+	it('should resolve "#" alias', () => {
+		resolver.resolveSync({}, "/", "#").should.be.eql("/c/dir/index");
+		resolver.resolveSync({}, "/", "#/index").should.be.eql("/c/dir/index");
+	});
+	it('should resolve "@" alias', () => {
+		resolver.resolveSync({}, "/", "@").should.be.eql("/c/dir/index");
+		resolver.resolveSync({}, "/", "@/index").should.be.eql("/c/dir/index");
+	});
 	it("should resolve an ignore module", () => {
 		resolver.resolveSync({}, "/", "ignored").should.be.eql(false);
 	});