-
-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix docs.rs show features #209
Conversation
Thanks, @light4. I ever didn't aware the feature flags were broken. 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manifest.jsonnet
Outdated
@@ -46,7 +46,7 @@ else | |||
|
|||
local INDEX_MANAGER_FILES = ['core/storage.js', 'index-manager.js']; | |||
json.addIcons(icons()) | |||
.addPermissions(['storage', 'unlimitedStorage']) | |||
.addPermissions(['storage', 'unlimitedStorage', 'webRequest', 'webRequestBlocking', '*://crates.io/api/v1/crates/*']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use Manifest V3 already, after loading into Chrome, it said: webRequestBlocking' requires manifest version of 2 or lower
. Actually, I think we can remove those permissions.
@@ -116,8 +116,9 @@ document.addEventListener("DOMContentLoaded", async () => { | |||
async function enhanceFeatureFlagsMenu(menu) { | |||
// Use rawCrateName to fetch the Cargo.toml, otherwise will get 404. | |||
let cargoTomUrl = `https://docs.rs/crate/${rawCrateName}/${crateVersion}/source/Cargo.toml`; | |||
let response = await fetch(cargoTomUrl); | |||
let content = await response.text(); | |||
let crateAPIURL = `https://crates.io/api/v1/crates/${rawCrateName}/${crateVersion}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The crateVersion
could be latest
which is invalid for the API of crates.io. For example: https://crates.io/api/v1/crates/tokio/latest
We should ensure the enhanceFeatureFlagsMenu()
function is called after crateVersion = parseCrateVersionFromDOM()
, see line 97.
Also, don't forget to remove |
Updated, should I rebase to one commit? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some nitpicking.
@@ -46,7 +46,7 @@ else | |||
|
|||
local INDEX_MANAGER_FILES = ['core/storage.js', 'index-manager.js']; | |||
json.addIcons(icons()) | |||
.addPermissions(['storage', 'unlimitedStorage']) | |||
.addPermissions(['storage', 'unlimitedStorage', '*://crates.io/api/v1/crates/*']) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can remove *://crates.io/api/v1/crates/*
too.
Permission '://crates.io/api/v1/crates/' is unknown or URL pattern is malformed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, Firefox says TypeError: NetworkError when attempting to fetch resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found this, will make an update.
https://www.extension.ninja/blog/post/solved-permission-is-unknown-or-url-pattern-is-malformed/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good to know. Thanks.
@@ -114,10 +114,14 @@ document.addEventListener("DOMContentLoaded", async () => { | |||
}); | |||
|
|||
async function enhanceFeatureFlagsMenu(menu) { | |||
if (crateVersion === 'latest') { | |||
crateVersion = parseCrateVersionFromDOM(); | |||
} | |||
// Use rawCrateName to fetch the Cargo.toml, otherwise will get 404. | |||
let cargoTomUrl = `https://docs.rs/crate/${rawCrateName}/${crateVersion}/source/Cargo.toml`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cargoTomUrl
is useless now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for reminding me.
I'll squash it into one commit. |
I'll merge it. We can fix the permission issue in the next PR. |
use crates.io to get deps info
I don't remember how it looks like before, any advice?