jupyterlab / jupyterlab/hatch-nodejs-version

The `repository` URL is not processed correctly when set as an object

Open
#32 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
10
Forks
7
PR merge metrics
No merged PRs in 30d

Description

Hi! 👋

## Description

If the `repository` URL is specified in the normalized form in the `package.json` file, similar to the example in the [`package.json` documentation](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#repository), the URL inserted as Python package metadata is not processed correctly, keeping the `git` affixes:

### `package.json`

```json
{
"repository": {
"type": "git",
"url": "git+https://gitlab.com/joaommpalmeiro/jupyterlab-eigenpal-docx-viewer.git"
}
}
```

### `PKG-INFO` (after building a JupyterLab extension, for example)

```plain
Project-URL: Repository, git+https://gitlab.com/joaommpalmeiro/jupyterlab-eigenpal-docx-viewer.git
```

## Reproduce

1. Create a JupyterLab extension from the [official template](https://github.com/jupyterlab/extension-template).
2. Define the [`repository` field](https://github.com/jupyterlab/extension-template/blob/78d2122a4e5e5d4fac624b285d54babb4d1811f7/template/package.json.jinja#L28-L31) as per the example shared above.
3. Build the Python package locally.
4. Unzip the source distribution (`.tar.gz` file) and open the `PKG-INFO` file.
5. Confirm the `Project-URL: Repository` field.

## Expected behavior

The URL defined in the Python package's metadata does not contain the `git` affixes (`https://gitlab.com/joaommpalmeiro/jupyterlab-eigenpal-docx-viewer` instead of `git+https://gitlab.com/joaommpalmeiro/jupyterlab-eigenpal-docx-viewer.git`).

I believe this issue can be solved by processing the `repository.url` field the same way the `repository` field is processed when it's defined as a string (and accounting for the `git` affixes):

https://github.com/jupyterlab/hatch-nodejs-version/blob/81c4612da14dec4b260bc956225fa24ab62b377e/hatch_nodejs_version/metadata_source.py#L162-L172

## Context

- https://github.com/npm/hosted-git-info

Let me know if I can open a PR to fix this issue. Thanks!

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.