Skip to content
Snippets Groups Projects

Restore old routes, enable user route as fallback.

Merged lain requested to merge restore-routes into develop
2 unresolved threads

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
1 const generateProfileLink = (id, screenName) => {
1 import { includes } from 'lodash'
2
3 const generateProfileLink = (id, screenName, restrictedNicknames) => {
4 const complicated = (isExternal(screenName) || includes(restrictedNicknames, screenName))
  • HJ
    HJ @hj started a thread on the diff
  • 1 const generateProfileLink = (id, screenName) => {
    1 import { includes } from 'lodash'
    2
    3 const generateProfileLink = (id, screenName, restrictedNicknames) => {
    4 const complicated = (isExternal(screenName) || includes(restrictedNicknames, screenName))
    2 5 return {
    3 name: (isExternal(screenName) ? 'external-user-profile' : 'user-profile'),
    4 params: (isExternal(screenName) ? { id } : { name: screenName })
    6 name: (complicated ? 'external-user-profile' : 'user-profile'),
    • Maintainer

      It's more complicated than you think! The more I look into this code the more i feel like unit tests are neccesary.

      • 'external-user-profile' and 'user-profile' are essentially same route URL-wise, with few gotchas that make me wonder how vue will react.
      • 'external-user-profile' uses id param and will probably break if you give it name param
      • 'user-profile' uses name param and has both optional part and extreme collisions - will { name: 'settings' } generate /settings or /user/settings?

      something must be done at least. Maybe change name to id for both routes to avoid superfluous branching?

    • To me it looks fairly safe and I would be ready to merge, but the concerns are valid. I'll never say no to more unit tests at least. Maybe the name param in user profile should be called userName instead?

    • This works as expected, for people on the restricted list, it will be generating the external style (domain.com/users/id), for normal nicknames it will generate domain.com/user names. The matching works from top to bottom. Refresh works normally as well.

    • Please register or sign in to reply
  • Maintainer

    some nitpickings, but otherwise looks good. I'd probably check how vue generates routes for colliding routes (see !440 (comment 11639)) and also maybe keep FE-specific list of reserved nicknames for BE (devs) to be aware of, but that's stuff for the future.

  • I think this whole component could use some refactoring, it's kinda hard to understand how it even branches between the different variants. I'll merge this now and refactor it right after.

  • merged

  • lain mentioned in commit 1555a5fe

    mentioned in commit 1555a5fe

  • Please register or sign in to reply
    Loading