Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: zotonic/zotonic
...
head fork: zotonic/zotonic
  • 3 commits
  • 7 files changed
  • 0 commit comments
  • 2 contributors
View
2  .gitmodules
@@ -21,4 +21,4 @@
url = git://github.com/zotonic/bert.erl.git
[submodule "deps/z_stdlib"]
path = deps/z_stdlib
- url = git@github.com:zotonic/z_stdlib.git
+ url = git://github.com/zotonic/z_stdlib.git
2  deps/z_stdlib
@@ -1 +1 @@
-Subproject commit ec76e03cc9bc29b89d71d1b42978ac4998898512
+Subproject commit f3a8cb8679adb570c6bc7fc311bd64dba78ca711
View
44 src/support/tests/z_convert_tests.erl
@@ -1,44 +0,0 @@
-%% @author Arjan Scherpenisse <arjan@scherpenisse.net>
-%% @hidden
-
--module(z_convert_tests).
-
--include_lib("zotonic.hrl").
-
--include_lib("eunit/include/eunit.hrl").
-
-
--define(assertDatetime(A, B), ?assertEqual(A, z_convert:to_datetime(B))).
-
-convert_date_test() ->
- ?assertEqual({2010,12,12}, z_convert:to_date("2010-12-12")),
- ?assertEqual({2010,12,12}, z_convert:to_date("2010/12/12")),
- ok.
-
-convert_time_test() ->
- ?assertEqual({1,23,0}, z_convert:to_time("01:23:00")),
- ?assertEqual({1,23,0}, z_convert:to_time("01:23")),
- ?assertEqual({1,23,59}, z_convert:to_time("01:23:59")),
- ok.
-
-convert_datetime_test() ->
-
- %% generic format
- ?assertDatetime({{2010,1,1},{18,23,50}}, "2010-01-01 18:23:50"),
- ?assertDatetime({{2010,1,1},{18,23,0}}, "2010-01-01 18:23"),
- ?assertDatetime({{2010,1,1},{0,0,0}}, "2010-01-01"),
-
- %% xsd:datetime
- ?assertDatetime({{2010,1,1},{18,29,39}}, "2010-01-01T18:29:39"),
- ?assertDatetime(calendar:universal_time_to_local_time({{2010,1,1},{18,29,39}}), "2010-01-01T18:29:39+00:00"),
- ?assertDatetime(calendar:universal_time_to_local_time({{2010,1,1},{18,29,39}}), "2010-01-01T18:29:39Z"),
- ?assertDatetime(calendar:universal_time_to_local_time({{2010,1,1},{17,29,39}}), "2010-01-01T18:29:39+01:00"),
- ?assertDatetime(calendar:universal_time_to_local_time({{2010,1,1},{20,29,39}}), "2010-01-01T18:29:39-02:00"),
-
- ?assertDatetime(calendar:universal_time_to_local_time({{2011,10,6},{14,44,0}}), "2011-10-06T16:44:00+0200"),
- ok.
-
-datetime_to_iso_test() ->
- ?assertEqual("2010-09-02T10:11:56Z", z_convert:to_isotime(calendar:universal_time_to_local_time({{2010,9,2},{10,11,56}}))),
- ?assertEqual("2010-09-02T01:01:01Z", z_convert:to_isotime(calendar:universal_time_to_local_time({{2010,9,2},{1,1,1}}))),
- ok.
View
13 src/support/tests/z_html_tests.erl
@@ -1,13 +0,0 @@
-%% @author Arjan Scherpenisse <arjan@scherpenisse.net>
-%% @hidden
-
--module(z_html_tests).
-
--include_lib("eunit/include/eunit.hrl").
--include_lib("zotonic.hrl").
-
-
-link_elements_test() ->
- ?assertEqual([[{"rel", "foo"}]], z_html:scrape_link_elements("<p>This is text.<link rel=\"foo\" /></p>")),
- ?assertEqual([[{"rel", "Foo"}]], z_html:scrape_link_elements("<p>This is text.<LINK REL=\"Foo\" /></p>")),
- ok.
View
71 src/support/tests/z_string_tests.erl
@@ -1,71 +0,0 @@
-%% @author Arjan Scherpenisse <arjan@scherpenisse.net>
-%% @hidden
-
--module(z_string_tests).
-
--include_lib("eunit/include/eunit.hrl").
--include_lib("zotonic.hrl").
-
-
-contains_test() ->
- ?assert(z_string:contains("", "strange case")),
- ?assert(z_string:contains("", "")),
- ?assert(z_string:contains("a", "a")),
- ?assert(z_string:contains("is", "This is text.")),
- ?assert(z_string:contains("This", "This is text.")),
- ?assert(z_string:contains("t.", "This is text.")),
- ?assertNot(z_string:contains("not", "This is text.")),
- ?assertNot(z_string:contains("n", "")),
- ?assertNot(z_string:contains("n", "b")),
- ok.
-
-starts_with_test() ->
- ?assert(z_string:starts_with("", "This is text.")),
- ?assert(z_string:starts_with("", "")),
- ?assert(z_string:starts_with("T", "This is text.")),
- ?assertNot(z_string:starts_with("t", "This is text.")),
- ?assert(z_string:starts_with("This", "This is text.")),
- ?assertNot(z_string:starts_with("Bla", "This is text.")),
- ?assert(z_string:starts_with(["This ", "is"], "This is text.")),
- ?assert(z_string:starts_with(["This ", <<"is">>], "This is text.")),
- ?assertNot(z_string:starts_with(["This ", <<"is not">>], "This is text.")),
- ok.
-
-ends_with_test() ->
- ?assert(z_string:ends_with("", "This is text.")),
- ?assert(z_string:ends_with("", "")),
- ?assert(z_string:ends_with(".", "This is text.")),
- ?assertNot(z_string:ends_with("T", "This is text.")),
- ?assert(z_string:ends_with("ext.", "This is text.")),
- ?assert(z_string:ends_with(["is ", "text."], "This is text.")),
- ?assert(z_string:ends_with(["is ", <<"text.">>], "This is text.")),
- ?assertNot(z_string:ends_with(["is ", <<"jpeg.">>], "This is text.")),
- ok.
-
-valid_utf8_test_() ->
- [
- ?_assert(v_utf8(<<>>)),
- ?_assert(v_utf8(<<127>>)),
- ?_assert(v_utf8(<<2#11001111, 2#10000000>>)),
- ?_assert(v_utf8(<<2#11011111, 2#10111111>>)),
-
- ?_assert(v_utf8(<<2#11101000, 2#10000000, 2#10000000>>)),
- ?_assert(v_utf8(<<2#11101111, 2#10111111, 2#10111101>>)),
-
- ?_assert(v_utf8(<<2#11110100, 2#10000000, 2#10000000, 2#10000000>>)),
- ?_assert(v_utf8(<<2#11110000, 2#10111111, 2#10111111, 2#10111111>>)),
-
- ?_assertNot(v_utf8(<<128>>)),
-
- ?_assertNot(v_utf8(<<2#11100000, 2#10000000>>)),
- ?_assertNot(v_utf8(<<2#11000000, 2#11000000>>)),
-
- ?_assertNot(v_utf8(<<2#11110000, 2#10000000, 2#10000000>>)),
- ?_assertNot(v_utf8(<<2#11100000, 2#11000000, 2#10000000>>)),
- ?_assertNot(v_utf8(<<2#11100000, 2#10000000, 2#11000000>>)),
-
- ?_assertNot(v_utf8(<<2#11111000, 2#10000000, 2#10000000, 2#10000000>>))
- ].
-
-v_utf8(Bin) ->
- z_string:sanitize_utf8(Bin) =:= Bin.
View
26 src/support/tests/z_utils_tests.erl
@@ -1,26 +0,0 @@
-%% @author Arjan Scherpenisse <arjan@scherpenisse.net>
-%% @hidden
-
--module(z_utils_tests).
-
--include_lib("eunit/include/eunit.hrl").
--include_lib("zotonic.hrl").
-
-
-url_encode_decode_test() ->
- Url = "index.html?x=y&z=1",
- ?assertEqual(Url, z_utils:url_decode(z_utils:url_encode(Url))).
-
-
-url_encode_test() ->
- ?assertEqual("foo+bar", z_utils:url_encode("foo bar")),
- ?assertEqual("foo%26bar", z_utils:url_encode("foo&bar")).
-
-url_decode_test() ->
- ?assertEqual("foo&bar", z_utils:url_decode("foo%26bar")).
-
-
-percent_encode_test() ->
- ?assertEqual("foo%20bar", z_utils:percent_encode("foo bar")),
- ?assertEqual("foo%26bar", z_utils:percent_encode("foo&bar")).
-
View
36 src/support/z_utils.erl
@@ -34,9 +34,7 @@
coalesce/1,
combine/2,
combine_defined/2,
- decode/2,
depickle/2,
- encode/2,
f/1,
f/2,
get_seconds/0,
@@ -151,35 +149,6 @@ erase_process_dict() ->
ok.
-%%% HEX ENCODE and HEX DECODE
-
-hex_encode(Data) -> encode(Data, 16).
-hex_decode(Data) -> decode(Data, 16).
-
-encode(Data, Base) when is_binary(Data) -> encode(binary_to_list(Data), Base);
-encode(Data, Base) when is_list(Data) ->
- F = fun(C) when is_integer(C) ->
- case erlang:integer_to_list(C, Base) of
- [C1, C2] -> [C1, C2];
- [C1] -> [$0, C1]
- end
- end,
- [F(I) || I <- Data].
-
-decode(Data, Base) when is_binary(Data) -> decode(binary_to_list(Data), Base);
-decode(Data, Base) when is_list(Data) ->
- inner_decode(Data, Base).
-
-inner_decode(Data, Base) when is_list(Data) ->
- case Data of
- [C1, C2|Rest] ->
- I = erlang:list_to_integer([C1, C2], Base),
- [I|inner_decode(Rest, Base)];
- [] ->
- []
- end.
-
-
%% Encode value securely, for use in cookies.
%% 50 usec on core2duo 2GHz
@@ -238,6 +207,11 @@ depickle(Data, Context) ->
_M:_E -> erlang:throw("Postback data invalid, could not depickle: "++Data)
end.
+%%% HEX ENCODE and HEX DECODE
+
+hex_encode(Value) -> z_url:hex_encode(Value).
+hex_decode(Value) -> z_url:hex_decode(Value).
+
%%% URL ENCODE %%%

No commit comments for this range

Something went wrong with that request. Please try again.