forked from GeopJr/Tuba
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: web+ap support * feat: tests
- Loading branch information
Showing
7 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// https://fedilinks.org/spec/en/6-The-web-ap-URI | ||
public class Tuba.WebApHandler { | ||
public static string from_uri (Uri uri) { | ||
return Uri.join ( | ||
uri.get_flags (), | ||
"https", | ||
uri.get_userinfo (), | ||
uri.get_host (), | ||
uri.get_port (), | ||
uri.get_path (), | ||
uri.get_query (), | ||
uri.get_fragment () | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,5 @@ sources += files( | |
'Locale.vala', | ||
'Tracking.vala', | ||
'Units.vala', | ||
'WebApHandler.vala', | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
struct TestUrl { | ||
public string original; | ||
public string result; | ||
} | ||
|
||
const TestUrl[] URLS = { | ||
{ "web+ap://www.gnome.org/", "https://www.gnome.org/" }, | ||
{ "web+ap://www.gnome.org/test", "https://www.gnome.org/test" }, | ||
{ "web+ap://www.gnome.org/test?foo=bar", "https://www.gnome.org/test?foo=bar" }, | ||
{ "web+ap://www.gnome.org/test?foo=bar&fizz=buzz", "https://www.gnome.org/test?foo=bar&fizz=buzz" }, | ||
{ "web+ap://www.gnome.org/test?foo=bar&fizz=buzz#main", "https://www.gnome.org/test?foo=bar&fizz=buzz#main" } | ||
}; | ||
|
||
public void test_web_ap_handler () { | ||
foreach (var test_url in URLS) { | ||
try { | ||
var uri = Uri.parse (test_url.original, UriFlags.NONE); | ||
|
||
assert_cmpstr (Tuba.WebApHandler.from_uri (uri), CompareOperator.EQ, test_url.result); | ||
} catch (Error e) { | ||
critical (e.message); | ||
} | ||
} | ||
} | ||
|
||
public int main (string[] args) { | ||
Test.init (ref args); | ||
|
||
Test.add_func ("/test_web_ap_handler", test_web_ap_handler); | ||
return Test.run (); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters