Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Produce correct relative URLs #509

Open
bbayles opened this issue Sep 6, 2023 · 3 comments
Open

Produce correct relative URLs #509

bbayles opened this issue Sep 6, 2023 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@bbayles
Copy link

bbayles commented Sep 6, 2023

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 and Python's 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.

@anonrig
Copy link
Member

anonrig commented Sep 6, 2023

URL spec for relative-URL string: https://url.spec.whatwg.org/#relative-url-string

@anonrig anonrig added enhancement New feature or request help wanted Extra attention is needed labels Nov 10, 2023
@ardinugrxha
Copy link

It seems good for me to give help to this, where is starting point to create those functions? src/ada_c.cpp ? or src/url.cpp

@lemire
Copy link
Member

lemire commented Nov 30, 2023

@ardi-nugraha

There are two underlying implementations, ada::url (simpler but slower) and ada::url_aggregator (faster but trickier). You could start with ada::url:

struct url : url_base {

Once it works, you could try with ada::url_aggregator:

struct url_aggregator : url_base {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants