clearlydefined / clearlydefined/service

Discuss name collision possibilities when we replace "/" with "." in namespaces

Open
#863 0 comments 0 reactions 0 assignees View on GitHub
design
Dominant language
TypeScript
Stars
51
Forks
46
PR merge metrics
No merged PRs in 30d

Description

## Background

In order to request a maven package, the API call would look like this:

```bash
curl -X GET https://clearlydefined.io/definitions/maven/mavencentral/com.apollographql.apollo3/apollo-runtime-jvm/3.0.0-dev14" -H "accept: */*"
```

In this case, the coordinates are maven/mavencentral/com.apollographql.apollo3/apollo-runtime-jvm/3.0.0-dev14

Let's break this down:
* **maven** is the **type**
* **mavencentral** is the **provider**
* **com.apollographql.apollo3** is the **namespace**
* **apollo-runtime-jvm** is the **name**
* **3.0.0-dev14** is the **revision**

When we run this API call:

```bash
curl -X GET https://clearlydefined.io/definitions/maven/mavencentral/com.apollographql.apollo3/apollo-runtime-jvm/3.0.0-dev14" -H "accept: */*"
```

It harvests the component from [here](https://repo1.maven.org/maven2/com/apollographql/apollo3/apollo-runtime-jvm/3.0.0-dev14/).

Notice something in the url - the namespace is "com/apollographql/apollo3" - there are a lot of slashes in there.

The way we translate this namespace into coordinates is to replace the slashes in the namespace with periods.

So "com/apollographql/apollo3" becomes "com.apollographql.apollo3".

We do the same thing with git components that come from gitlab and will need to do the same with Go components (see #862 for more details).

## Potential problem

It's unlikely, but it's possible we could run into name collisions by using this technique. For example - these two paths for two different go components would map to the same set of coordinates.

```
github.com/user/repo/pkg -> ["github.com.user.repo", "pkg"]
github.com/user.repo/pkg -> ["github.com.user.repo", "pkg"]
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.