Skip to content

Commit

Permalink
Fix index ID creation
Browse files Browse the repository at this point in the history
Meilisearch index UID only allows alphanumeric characters,
hyphens, and underscores. With this change, we handle dict
bundle identifiers correctly so that a valid UID is always
created from them.

This fixes the issue described in
https://www.alfredforum.com/topic/16134-better-dictionaries/page/5/#findComment-117683
  • Loading branch information
mr-pennyworth committed Dec 21, 2024
1 parent 1b2fed2 commit b6dc609
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ Subsequent searches should be snappy
<key>variablesdontexport</key>
<array/>
<key>version</key>
<string>0.2.17</string>
<string>0.2.18</string>
<key>webaddress</key>
<string>https://github.com/mr-pennyworth/alfred-better-dictionaries</string>
</dict>
Expand Down
6 changes: 4 additions & 2 deletions pyapp/BetterDict.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,10 @@ def all_dict_paths():


def get_dict_id(info):
# meilisearch index doesn't allow periods in name
return info["CFBundleIdentifier"].replace(".", "-")
# meilisearch index only allows alphanumeric characters, hyphens, and
# underscores in the index name, so replace all other characters with
# hyphens.
return re.sub(r"[^a-zA-Z0-9_-]", "-", info["CFBundleIdentifier"])


def get_dict_name(info):
Expand Down

0 comments on commit b6dc609

Please sign in to comment.