Skip to content

Commit baa39ec

Browse files
Fix to hyphenated taxonomies from uri (#156)
--------- Co-authored-by: Ryan Mitchell <[email protected]>
1 parent 4124574 commit baa39ec

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Taxonomies/TermRepository.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function findByUri(string $uri, string $site = null): ?TermContract
6969
return null;
7070
}
7171

72-
if (! $taxonomy = $this->findTaxonomyHandleByUri($taxonomy)) {
72+
if (! $taxonomy = $this->findTaxonomyHandleByUri(Str::ensureLeft($taxonomy, '/'))) {
7373
return null;
7474
}
7575

@@ -92,7 +92,9 @@ public function findByUri(string $uri, string $site = null): ?TermContract
9292

9393
private function findTaxonomyHandleByUri($uri)
9494
{
95-
return Taxonomy::findByHandle($uri)?->handle();
95+
return Taxonomy::all()->first(function ($taxonomy) use ($uri) {
96+
return $taxonomy->uri() == $uri;
97+
})?->handle();
9698
}
9799

98100
public function save($entry)

0 commit comments

Comments
 (0)