Append fetch query parameters before the URL fragment

Aberta
#88 2 comentários 0 reações 1 responsável Ver no GitHub

@abhinandanjoshii já está trabalhando nisso.

Desde 10/9/2026.

Avaliação

Esta issue ainda não foi avaliada.

Descrição

bug good first issue

Problem

_build_request() in src/pythonnative/net.py appends encoded params to the end of the entire URL. If the URL contains a fragment, the new parameters become part of that fragment and aren't sent to the server.

Confirmed example:

url:      https://example.test/items?existing=1#details
params:   {"q": "hello world"}
current:  https://example.test/items?existing=1#details&q=hello+world
expected: https://example.test/items?existing=1&q=hello+world#details

The current request's selector is /items?existing=1, so the server never receives q.

Requested change

Use urllib.parse.urlsplit() and urlunsplit() to append to the query component while preserving the fragment. Keep urlencode(..., doseq=True) so list-valued parameters continue to work.

Acceptance criteria

  • Tests cover URLs with neither query nor fragment, an existing query, a fragment, and both.
  • Existing query parameters remain intact, including repeated keys and encoded values.
  • List-valued parameters still become repeated query parameters.
  • Assert the outgoing Request.selector includes the added parameters and excludes the fragment; assert the URL's fragment is preserved separately.
  • Empty or absent params leave the URL unchanged.

Starting points and verification

Add focused request-construction tests in tests/test_net.py; these cases don't need a server or network. Keep this change focused on URL assembly so it can be reviewed independently of request header handling.

uv run pytest tests/test_net.py -q
./scripts/check.sh

Suggested commit message

Following CONTRIBUTING.md:

fix(net): append query parameters before URL fragments

Before starting

Please follow the issue-claiming process: check for an assignee or linked pull request, comment to claim the issue, and wait for a maintainer to assign it before opening a pull request. Contributor setup is in CONTRIBUTING.md.

Linguagem predominante
Python
Estrelas
131
Forks
22
Merge médio
3d 2h
PRs com merge (30d)
5

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de pythonnative/pythonnative

Todas as issues de pythonnative/pythonnative

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.