diff options
| author | Ben Busby <contact@benbusby.com> | 2022-06-09 13:08:01 -0600 |
|---|---|---|
| committer | Ben Busby <contact@benbusby.com> | 2022-06-09 13:08:01 -0600 |
| commit | 5006b97dfa42f9338bc2ee7080b79d37d4343cfa (patch) | |
| tree | f479012e8e08a292201a822e14fbdea748982577 /test/farside_test.exs | |
| parent | ff8d220e900004671f9e52f56d4b47c3ca7a40d6 (diff) | |
| download | farside-5006b97dfa42f9338bc2ee7080b79d37d4343cfa.tar.gz | |
Auto select frontend for links to "parent" service
Farside now supports redirecting based on a provided link to a "parent"
service, if such a parent service is supported.
For example, a link such as:
farside.link/https://www.youtube.com/watch?v=dQw4w9WgXcQ
will now redirect to any of the available YouTube related frontends.
This works by matching against a mapping of "parent" service domains
("youtube.com", "reddit.com", etc) to a list of their respective frontend
alternatives (["invidious", "piped"], ["libreddit", "teddit"], etc). A
random element is chosen from this list, and the remainder of Farside's
routing logic proceeds as if the user had chosen the service directly to
begin with.
Closes #37
Diffstat (limited to 'test/farside_test.exs')
| -rw-r--r-- | test/farside_test.exs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/farside_test.exs b/test/farside_test.exs index 05497f3..25828c6 100644 --- a/test/farside_test.exs +++ b/test/farside_test.exs @@ -77,4 +77,22 @@ defmodule FarsideTest do assert first_redirect != second_redirect end) end + + test "/https://..." do + parent_service = "https://www.youtube.com" + parent_path = "watch?v=dQw4w9WgXcQ" + conn = test_conn("/#{parent_service}/#{parent_path}") + + redirect = elem(List.last(conn.resp_headers), 1) + + IO.puts("") + IO.puts(" /#{parent_service}/#{parent_path}") + IO.puts(" redirected to") + IO.puts(" #{redirect}") + + assert conn.state == :set + assert conn.status == 302 + assert redirect =~ parent_path + assert !(redirect =~ parent_service) + end end |
