diff options
author | bep <bjorn.erik.pedersen@gmail.com> | 2015-02-17 04:33:44 +0100 |
---|---|---|
committer | bep <bjorn.erik.pedersen@gmail.com> | 2015-02-17 11:07:24 +0100 |
commit | c2e29138728ffbae19b4b0a3e59503c47dd986a5 (patch) | |
tree | 407b3eb0e80bc5ff568236d1e021147d62c563e5 /transform/chain_test.go | |
parent | 6b28e38cea0dec3e3f045ab8ec833608b91a946f (diff) |
Fix canonifyurl vs schemaless links
And looks even faster:
Compared to previous attempt:
benchmark old ns/op new ns/op delta
BenchmarkAbsUrl 30902 27206 -11.96%
BenchmarkXmlAbsUrl 15389 14216 -7.62%
benchmark old allocs new allocs delta
BenchmarkAbsUrl 33 28 -15.15%
BenchmarkXmlAbsUrl 16 14 -12.50%
benchmark old bytes new bytes delta
BenchmarkAbsUrl 4167 3504 -15.91%
BenchmarkXmlAbsUrl 2057 2048 -0.44%
Compared to before I started all of this:
benchmark old ns/op new ns/op delta
BenchmarkAbsUrl 36219 27206 -24.88%
BenchmarkXmlAbsUrl 23903 14216 -40.53%
benchmark old allocs new allocs delta
BenchmarkAbsUrl 60 28 -53.33%
BenchmarkXmlAbsUrl 30 14 -53.33%
benchmark old bytes new bytes delta
BenchmarkAbsUrl 5842 3504 -40.02%
BenchmarkXmlAbsUrl 3754 2048 -45.44%
Fixes #816
Diffstat (limited to 'transform/chain_test.go')
-rw-r--r-- | transform/chain_test.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/transform/chain_test.go b/transform/chain_test.go index a88d84533..cd7749ec7 100644 --- a/transform/chain_test.go +++ b/transform/chain_test.go @@ -21,6 +21,12 @@ const H5_XML_CONTENT_GUARDED = "<?xml version=\"1.0\" encoding=\"utf-8\" standal const REPLACE_1 = "No replacements." const REPLACE_2 = "ᚠᛇᚻ ᛒᛦᚦ ᚠᚱᚩᚠᚢᚱ\nᚠᛁᚱᚪ ᚷᛖᚻᚹᛦᛚᚳᚢᛗ" +// Issue: 816, schemaless links combined with others +const REPLACE_SCHEMALESS_HTML = `Pre. src='//schemaless' src='/normal' <a href="//schemaless">Schemaless</a>. <a href="/normal">normal</a>. Post.` +const REPLACE_SCHEMALESS_HTML_CORRECT = `Pre. src='//schemaless' src='http://base/normal' <a href="//schemaless">Schemaless</a>. <a href="http://base/normal">normal</a>. Post.` +const REPLACE_SCHEMALESS_XML = `Pre. src="//schemaless" src="/normal" <a href='//schemaless'>Schemaless</a>. <a href='/normal'>normal</a>. Post.` +const REPLACE_SCHEMALESS_XML_CORRECT = `Pre. src="//schemaless" src="http://base/normal" <a href='//schemaless'>Schemaless</a>. <a href='http://base/normal'>normal</a>. Post.` + var abs_url_bench_tests = []test{ {H5_JS_CONTENT_DOUBLE_QUOTE, CORRECT_OUTPUT_SRC_HREF_DQ}, {H5_JS_CONTENT_SINGLE_QUOTE, CORRECT_OUTPUT_SRC_HREF_SQ}, @@ -34,8 +40,10 @@ var xml_abs_url_bench_tests = []test{ } var sanity_tests = []test{{REPLACE_1, REPLACE_1}, {REPLACE_2, REPLACE_2}} -var abs_url_tests = append(abs_url_bench_tests, sanity_tests...) -var xml_abs_url_tests = append(xml_abs_url_bench_tests, sanity_tests...) +var extra_tests_html = []test{{REPLACE_SCHEMALESS_HTML, REPLACE_SCHEMALESS_HTML_CORRECT}} +var abs_url_tests = append(abs_url_bench_tests, append(sanity_tests, extra_tests_html...)...) +var extra_tests_xml = []test{{REPLACE_SCHEMALESS_XML, REPLACE_SCHEMALESS_XML_CORRECT}} +var xml_abs_url_tests = append(xml_abs_url_bench_tests, append(sanity_tests, extra_tests_xml...)...) func TestChainZeroTransformers(t *testing.T) { tr := NewChain() |