Skip to content

refactor: decouple username parsing from URL path using backend meta … - #537

Open
Yashaswini-K-P wants to merge 1 commit into
codepvg:mainfrom
Yashaswini-K-P:feature/decouple-username-meta-tag
Open

refactor: decouple username parsing from URL path using backend meta …#537
Yashaswini-K-P wants to merge 1 commit into
codepvg:mainfrom
Yashaswini-K-P:feature/decouple-username-meta-tag

Conversation

@Yashaswini-K-P

Copy link
Copy Markdown
Contributor

Description

Decoupled username parsing from fragile URL path segments (window.location.pathname.split("/")) by implementing a reliable backend meta-tag injection pattern. The backend now injects the current username into a <meta> tag within user.html, and a centralized frontend helper (utils.js) safely retrieves it.

Linked Issue

Fixes #354

Changes Made

  • Created utils.js with a centralized getCurrentUsername() helper to read the current-user meta tag.
  • Updated profile-controller.js to remove fragile path-splitting logic and use the new helper function.
  • Updated server.js to dynamically replace and inject the __USERNAME__ placeholder into user.html on request.
  • Added the <meta name="current-user" content="__USERNAME__"> tag to frontend/user.html.

Type of Change

  • Bug fix
  • New feature
  • UI/Visual update
  • Documentation update
  • Refactor

Testing

  • Tested locally
  • Tested on mobile viewport (if applicable)
  • No console errors introduced

Checklist

  • My code follows the project's coding style
  • I have formatted my code locally by running npx prettier --write . before submitting
  • I am submitting my PR from a dedicated feature/* branch, not the main branch
  • I have performed a self-review of my code
  • My changes generate no new warnings or errors
  • I have updated documentation if required
  • I have linked the relevant issue

Screenshots / Screen Recording

(Not applicable - backend/refactoring change)

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for submitting a pull request.

Please ensure your changes comply with the project's contribution guidelines and that all workflow checks pass successfully.

Formatting and Branching

  • Please confirm you have formatted your code locally using npx prettier --write . before requesting a review.
  • Ensure this PR is made from a feature/* branch and not main.

Note: This project is currently maintained by a solo maintainer, so reviews and responses may sometimes take a little time. Thanks for your patience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue: Improve Username Retrieval Logic

1 participant