Skip to content

Commit

Permalink
fix: accessKey not effective
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Dec 15, 2023
1 parent 190aa14 commit 393b003
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 13 deletions.
5 changes: 0 additions & 5 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ const storage = new Storage()
export const defaultConfig = {
rsshubDomain: 'https://rsshub.app',
rsshubAccessControl: {
enabled: false,
accessKey: '',
useCode: true,
},
notice: {
badge: true,
Expand Down Expand Up @@ -55,9 +53,6 @@ export async function setConfig(config: Partial<typeof defaultConfig>) {
config.rsshubDomain = defaultConfig.rsshubDomain;
}
config.rsshubDomain = config.rsshubDomain.replace(/\/$/, '');
if (config.rsshubDomain === defaultConfig.rsshubDomain) {
config.rsshubAccessControl.enabled = defaultConfig.rsshubAccessControl.enabled;
}
await storage.set("config", config)
toast.success("Saved")
return config;
Expand Down
2 changes: 0 additions & 2 deletions src/options/routes/General.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ function General() {
id="accessKey"
value={config.rsshubAccessControl.accessKey} onChange={(e) => setConfig({
rsshubAccessControl: {
enabled: !!e.target.value,
accessKey: e.target.value,
useCode: true,
}
})}
placeholder={chrome.i18n.getMessage("configurationRequiredIfAccessKeysEnabled")}
Expand Down
8 changes: 2 additions & 6 deletions src/popup/RSSItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@ function RSSItem({
}, [copied])

let url = item.url.replace('{rsshubDomain}', config.rsshubDomain);
if (type === 'currentPageRSS' && config.rsshubAccessControl.enabled) {
if (config.rsshubAccessControl.useCode) {
url = `${url}?code=${new MD5().update(item.path + config.rsshubAccessControl.accessKey).digest('hex')}`
} else {
url = `${url}?key=${config.rsshubAccessControl.accessKey}`
}
if (type === 'currentPageRSSHub' && config.rsshubAccessControl.accessKey) {
url = `${url}?code=${new MD5().update(item.path + config.rsshubAccessControl.accessKey).digest('hex')}`
}
url = encodeURI(url);
const encodedUrl = encodeURIComponent(url);
Expand Down

0 comments on commit 393b003

Please sign in to comment.