Skip to content

Commit 3cd59cf

Browse files
authored
Merge pull request #210 from OpenSourceOrg/fix/add-spdx-filter__dev
Do not cast the term to regex if no wildcards to avoid the issues a t…
2 parents ab767e9 + 226699e commit 3cd59cf

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

mu-plugins/osi-api/osi-api.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,10 @@ public function get_licenses( WP_REST_Request $data ) {
136136

137137
$args['post_title_like'] = sanitize_text_field( $searched_slug ); // Use the post name (slug) to filter by ID
138138
} elseif ( ! empty( $spdx ) ) {
139-
// Cast the term to a regex pattern
140-
$regex = $this->cast_wildcard_to_regex( $spdx );
141-
142139
// If we have no wildcards, look for a direct match
143140
$args['meta_query'][] = array(
144141
'key' => 'spdx_identifier_display_text',
145-
'value' => $regex,
142+
'value' => str_contains( $spdx, '*' ) ? $this->cast_wildcard_to_regex( $spdx ) : sanitize_text_field( $spdx ),
146143
'compare' => str_contains( $spdx, '*' ) ? 'REGEXP' : '==',
147144
);
148145
} elseif ( ! empty( $keyword ) ) {

0 commit comments

Comments
 (0)