Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: infoq detection logic#177

Merged
timerring merged 1 commit intomainfrom
dev
Feb 9, 2026
Merged

fix: infoq detection logic#177
timerring merged 1 commit intomainfrom
dev

Conversation

@timerring
Copy link
Member

Summary

Fixed InfoQ platform user detection by switching from the deprecated /public/v1/my/menu endpoint (which returns 404) to the working /public/v1/user/get_user API endpoint.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • Created new packages/detection/src/platforms/infoq.js file with detection logic
  • Added detectInfoQUser import and registration in packages/detection/src/detect.js
  • Implemented POST request to /public/v1/user/get_user API endpoint

Implementation Details

Root Cause:

The original InfoQ detection used the /public/v1/my/menu endpoint, which now returns 404 and is no longer available.

Key Changes:

  • Use POST request to /public/v1/user/get_user endpoint with credentials: 'include' to maintain session
  • Send empty JSON body {} as required by the API
  • Parse user information from response JSON data object
  • Extract nickname and avatar fields for user identification
  • Convert avatar URLs to base64 using convertAvatarToBase64 utility when avatar is hosted on geekbang.org to bypass CORS restrictions

Technical Notes:

  • Checks response status code and JSON structure for proper error handling
  • Validates login status by checking code === 0 and presence of uid
  • Properly handles missing data with optional chaining and fallback values
  • Avatar conversion prevents CORS issues when displaying user images from geekbang.org domain

Testing

Testing Checklist

  • I have tested this code locally
  • I have tested on the affected platform(s)
  • I have verified the changes work in the target browser(s)

Manual Testing Steps

  1. Log in to InfoQ in the browser
  2. Load the extension/application
  3. Verify that InfoQ user detection works correctly
  4. Confirm username and avatar are properly extracted and displayed

Screenshots/Videos

N/A

Additional Notes

This fix uses the current working API endpoint and follows the same pattern as other platform detectors in the codebase.

@timerring timerring self-assigned this Feb 9, 2026
@timerring timerring added the enhancement New feature or request label Feb 9, 2026
Copy link
Member Author

@timerring timerring left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@timerring timerring merged commit 9d19e91 into main Feb 9, 2026
@timerring timerring deleted the dev branch February 9, 2026 03:14
@timerring timerring linked an issue Feb 21, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

infoq 博客园登录状态的bug

1 participant