ada-url / ada-url/ada

Produce correct relative URLs

Open
#509 3 comments 0 reactions 0 assignees View on GitHub
enhancement help wanted
Dominant language
C++
Stars
1.8k
Forks
142
Avg merge
19h 11m
Merged PRs (30d)
24

Description

### What is the problem this feature will solve?

The URL Standard describes how to combine a string with a relative path with a base URL to produce a valid absolute URL.

This feature request is: given an absolute URL and a base URL, produce a string with a relative path that when joined to the base URL, would produce the original absolute URL.

This is similar to file system path operations like Go's [Rel](https://pkg.go.dev/path/filepath#Rel) and Python's [relpath](https://docs.python.org/3/library/os.path.html#os.path.relpath).

Practical application: some HLS video players expect relative paths, despite the HLS spec allowing for absolute paths. I want to produce correct relative paths given the relevant absolute ones.

### What is the feature you are proposing to solve the problem?

Some function like:

```
ada_relative_path(base, input)
```

Example:
* base: `https://example.org:8080/origin/multivariant/playlist.m3u8`
* input: `https://example.org:8080/origin/media/1080p.m3u8`
* output: `../media/1080p.m3u8`
* validate: parse output with base, get back input

### What alternatives have you considered?

Using the file system tools.

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.