deeplinks: switchdash_to_gateway rejects a deeplink whose host differs in case

Open Beginner friendly
#471 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start in core/switch_core/deeplinks.py at switchdash_to_gateway, then review the existing cases in core/tests/switch_core/test_deeplinks.py. Add coverage for a deeplink whose host differs in case and verify that it is accepted rather than returning None. Run the deeplink tests; done means the mixed-case host follows the same rewrite path as the lowercase host.

Written by the indexing model from the issue text.

Description

switchdash_to_gateway in core/switch_core/deeplinks.py compares parts.netloc against the literal "session":

if parts.scheme != _DEEPLINK_SCHEME or parts.netloc != _DEEPLINK_HOST:
    return None

urlsplit normalises the scheme to lower case but leaves netloc exactly as written. So the two halves of that check are not symmetric:

>>> urlsplit('SWITCHDASH://Session?server=a&room=b')
scheme='switchdash'   netloc='Session'

A deeplink of the form switchdash://Session?… therefore returns None, and deeplink_for_platform falls back to posting the raw custom-scheme URL. On a platform that does not linkify custom schemes — Discord, which is the reason this rewrite exists — the user sees unclickable plain text instead of an "Open in Switch Console" link. It fails quietly: nothing logs, and the only symptom is a link that does not work.

Hosts are case-insensitive, so the comparison should be too. Case-folding netloc before the comparison would fix it.

Worth a test alongside the existing cases in core/tests/switch_core/test_deeplinks.py.

Dominant language
Python
Stars
646
Forks
52
Avg merge
1d 9h
Merged PRs (30d)
137

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sandbox-quantum/switch

All issues in sandbox-quantum/switch

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.