-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZZCS-33 Fix a problem where incorrect language results would be retur…
…ned for dbpedia fetches (#743) * ZZCS-33 Fix a problem where incorrect language results would be returned for dbpedia fetches * Cleanup http/https usage and language selection.
- Loading branch information
Showing
5 changed files
with
171 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,39 @@ | ||
%% @doc HTTP URIs. | ||
%% Note that these routines also accept "httpss:", as that is a mistake | ||
%% that does occur in some datasets we are using and we can't fix at | ||
%% the source of those datasets. | ||
|
||
-module(ginger_uri). | ||
|
||
-export([ | ||
uri/1, | ||
https/1 | ||
https/1, | ||
http/1 | ||
]). | ||
|
||
-type(uri() :: binary()). | ||
-type uri() :: binary(). | ||
|
||
-export_type([ | ||
uri/0 | ||
]). | ||
|
||
%% @doc Construct a URI. | ||
%% @doc Construct a URI, ensure that the URL has http or https protocol. | ||
-spec uri(binary()) -> uri(). | ||
uri(<<"http://", _/binary>> = Uri) -> | ||
Uri; | ||
uri(<<"https://", _/binary>> = Uri) -> | ||
Uri. | ||
uri(<<"http://", _/binary>> = Uri) -> Uri; | ||
uri(<<"https://", _/binary>> = Uri) -> Uri; | ||
uri(<<"httpss://", Uri/binary>>) -> <<"https://", Uri/binary>>; | ||
uri(<<"//", _/binary>> = Uri) -> <<"https:", Uri/binary>>. | ||
|
||
%% @doc Force a URI to be HTTPS. | ||
-spec https(uri()) -> uri(). | ||
https(<<"http://", Uri/binary>>) -> | ||
<<"https://", Uri/binary>>; | ||
https(<<"https://", _/binary>> = Uri) -> | ||
Uri; | ||
https(<<"httpss://", Uri/binary>>) -> | ||
<<"https://", Uri/binary>>. | ||
-spec https(binary()) -> uri(). | ||
https(<<"//", _/binary>> = Uri) -> <<"https:", Uri/binary>>; | ||
https(<<"http://", Uri/binary>>) -> <<"https://", Uri/binary>>; | ||
https(<<"https://", _/binary>> = Uri) -> Uri; | ||
https(<<"httpss://", Uri/binary>>) -> <<"https://", Uri/binary>>. | ||
|
||
%% @doc Force a URI to be HTTP. | ||
-spec http(binary()) -> uri(). | ||
http(<<"//", _/binary>> = Uri) -> <<"http:", Uri/binary>>; | ||
http(<<"http://", _/binary>> = Uri) -> Uri; | ||
http(<<"https://", Uri/binary>>) -> <<"http://", Uri/binary>>; | ||
http(<<"httpss://", Uri/binary>>) -> <<"http://", Uri/binary>>. |
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