diff --git a/gitignore_parser.py b/gitignore_parser.py
index c8a7771..5ce75f8 100644
--- a/gitignore_parser.py
+++ b/gitignore_parser.py
@@ -102,7 +102,7 @@ def rule_from_pattern(pattern, base_path=None, source=None):
 			if striptrailingspaces:
 				pattern = pattern[:i]
 		i = i - 1
-	regex = fnmatch_pathname_to_regex(pattern)
+	regex = fnmatch_pathname_to_regex(pattern, directory_only)
 	if anchored:
 		regex = ''.join(['^', regex])
 	return IgnoreRule(
@@ -147,7 +147,7 @@ class IgnoreRule(collections.namedtuple('IgnoreRule_', IGNORE_RULE_FIELDS)):
 
 # Frustratingly, python's fnmatch doesn't provide the FNM_PATHNAME
 # option that .gitignore's behavior depends on.
-def fnmatch_pathname_to_regex(pattern):
+def fnmatch_pathname_to_regex(pattern, directory_only: bool):
 	"""
 	Implements fnmatch style-behavior, as though with FNM_PATHNAME flagged;
 	the path separator will not match shell-style '*' and '.' wildcards.
@@ -201,5 +201,6 @@ def fnmatch_pathname_to_regex(pattern):
 		else:
 			res.append(re.escape(c))
 	res.insert(0, '(?ms)')
-	res.append('$')
-	return ''.join(res)
\ No newline at end of file
+	if not directory_only:
+		res.append('$')
+	return ''.join(res)

diff --git a/tests.py b/tests.py
index 6b28b64..c1b6aad 100644
--- a/tests.py
+++ b/tests.py
@@ -74,6 +74,18 @@ class Test(TestCase):
 		self.assertTrue(matches('/home/michael/othermatch'))
 		self.assertTrue(matches('/home/michael/#imnocomment'))
 
+	def test_ignore_directory(self):
+		matches = _parse_gitignore_string('.venv/', fake_base_dir='/home/michael')
+		self.assertTrue(matches('/home/michael/.venv'))
+		self.assertTrue(matches('/home/michael/.venv/folder'))
+		self.assertTrue(matches('/home/michael/.venv/file.txt'))
+
+	def test_ignore_directory_astrix(self):
+		matches = _parse_gitignore_string('.venv/*', fake_base_dir='/home/michael')
+		self.assertFalse(matches('/home/michael/.venv'))
+		self.assertTrue(matches('/home/michael/.venv/folder'))
+		self.assertTrue(matches('/home/michael/.venv/file.txt'))
+
 	def test_negation(self):
 		matches = _parse_gitignore_string(
 			'''

Bug with matching paths within .gitignore directory
Is this correct? It feels like a bug to me since it works when you specify the rule in `.gitignore`.


Imagine `.gitignore` contents including

```
.venv/
```


And a script evaluating this

```
gitignore_matcher('/path/to/repo/.venv/')
True
gitignore_matcher('/path/to/repo/.venv/bin')
False
```

To me the second one should return `True`
tests.py::Test::test_ignore_directory
tests.py::Test::test_anchored_wildcard tests.py::Test::test_comment tests.py::Test::test_ignore_directory_astrix tests.py::Test::test_negation tests.py::Test::test_simple tests.py::Test::test_trailingspaces tests.py::Test::test_wildcard