Repository: huhu/rust-search-extension (language: rust)

Issue:
Wrong crate is added when the crate name does not match the lib name.
I wanted to add [md-5](https://crates.io/crates/md-5) crate whose [lib name is md5](https://github.com/RustCrypto/hashes#crate-names) but actually added [md5](https://crates.io/crates/md5) crate with the version number of md-5.


Discussion / hints:

Fix patch:
diff --git a/extension/script/docs-rs.js b/extension/script/docs-rs.js
index c51d909a..32e69a74 100644
--- a/extension/script/docs-rs.js
+++ b/extension/script/docs-rs.js
@@ -3,7 +3,7 @@
 // Here actix-web is the rawCrateName, actix_web is the crateName.
 // The rawCrateName mainly for Cargo.toml url to parse feature flags.
 let pathname = location.pathname.replace("/crate", "");
-let [rawCrateName, crateVersion] = pathname.slice(1).split("/");
+let [rawCrateName, crateVersion, targetCrateName] = pathname.slice(1).split("/");
 let crateName = rawCrateName.replaceAll("-", "_");
 // A crate version which added to the extension.
 let installedVersion = undefined;
@@ -91,6 +91,11 @@ document.addEventListener("DOMContentLoaded", async () => {
         // Query installed crates from chrome.storage API
         let crates = await storage.getItem("crates") || {};
         let crate = crates[crateName];
+        if(!crate && crates[targetCrateName]) {
+            crate = crates[targetCrateName];
+            crateName = targetCrateName;
+        }
+
         if (crate) {
             insertAddToExtensionElement(getState(crate.version));
         } else {


Test patch: