<commit_before><!DOCTYPE html>
<html>
<head>
    <title>Dragonfly - URI class</title>
    <link rel="stylesheet" href="qunit/qunit.css" media="screen">
    <script src="qunit/qunit.js"></script>
    <script src="../src/scripts/uri.js"></script>


<script>


test("uri", function()
{ 
  var uri = new URI("http://edition.cnn.com/.element/ssi/intl/breaking_news/3.0/banner.html?csiID=csi1#hello");

  equal(uri.protocol, "http:");
  equal(uri.host, "edition.cnn.com");
  equal(uri.pathname, "/.element/ssi/intl/breaking_news/3.0/banner.html");
  equal(uri.search, "?csiID=csi1");
  equal(uri.hash, "#hello");
  equal(uri.filename, "banner.html");
  equal(uri.extension, "html");
  equal(uri.dir_pathname, "/.element/ssi/intl/breaking_news/3.0/");
  equal(uri.abs_dir, "http://edition.cnn.com/.element/ssi/intl/breaking_news/3.0/");
  deepEqual(uri.params, [{key: "csiID", value: "csi1"}]);
  deepEqual(uri.path_parts, [".element", "ssi", "intl", "breaking_news", "3.0", "banner.html"]);
  equal(uri.short_distinguisher, "banner.html?csiID=csi1#hello");

  var uri = new URI("foo.txt");

  equal(uri.protocol, "");
  equal(uri.host, "");
  equal(uri.pathname, "foo.txt");
  equal(uri.search, "");
  equal(uri.hash, "");
  equal(uri.filename, "foo.txt");
  equal(uri.extension, "txt");
  equal(uri.dir_pathname, "");
  equal(uri.abs_dir, "");
  deepEqual(uri.params, []);
  deepEqual(uri.path_parts, ["foo.txt"]);
  equal(uri.short_distinguisher, "foo.txt");

  // Tests for params
  var uri = new URI("foo?one=two&one=three");
  deepEqual(uri.params, [{key: "one", value: "two"}, {key: "one", value: "three"}]);

  var uri = new URI("foo?one=two&one=&do=true");
  deepEqual(uri.params, [{key: "one", value: "two"}, {key: "one", value: ""}, {key: "do", value:"true"}]);

  var uri = new URI("foo?one=two&one&do=true");
  deepEqual(uri.params, [{key: "one", value: "two"}, {key: "one", value: ""},{key: "do", value: "true"}]);

  var uri = new URI("foo?hasOwnProperty=yup&constructor=me=true");
  deepEqual(uri.params, [{key: "hasOwnProperty", value: "yup"}, {key: "constructor", value: "me=true"}]);

  var uri = new URI("foo.txt?on?e=two&one");
  deepEqual(uri.params, [{key: "on?e", value: "two"}, {key: "one", value: ""}]);

  var uri = new URI("foo.txt?one=two&&&ne&do=true");
  deepEqual(uri.params, [{key: "one", value: "two"}, {key: "ne", value: ""}, {key: "do", value: "true"}]);

  var uri = new URI("?do=true%20%26amp;%20for_real&true%20%26amp;%20for_real=yes");
  deepEqual(uri.params, [{key: "do", value: "true &amp; for_real"}, {key: "true &amp; for_real", value: "yes"}]);

  // tests for short_distinguisher
  var uri = new URI("bar/foo?one=two&one=three#hash");
  equal(uri.short_distinguisher, "foo?one=two&one=three#hash");

  var uri = new URI("bar/foo#hash");
  equal(uri.short_distinguisher, "foo#hash");

  var uri = new URI("bar/foo?q");
  equal(uri.short_distinguisher, "foo?q");

  var uri = new URI("bar/?q");
  equal(uri.short_distinguisher, "?q");

  var uri = new URI("bar/#h1");
  equal(uri.short_distinguisher, "#h1");

  var uri = new URI("foo/bar/");
  equal(uri.short_distinguisher, "bar");
  
});


<commit_msg>Added test for data: URIs.<commit_after><!DOCTYPE html>
<html>
<head>
    <title>Dragonfly - URI class</title>
    <link rel="stylesheet" href="qunit/qunit.css" media="screen">
    <script src="qunit/qunit.js"></script>
    <script src="../src/scripts/uri.js"></script>


<script>


test("uri", function()
{ 
  var uri = new URI("http://edition.cnn.com/.element/ssi/intl/breaking_news/3.0/banner.html?csiID=csi1#hello");

  equal(uri.protocol, "http:");
  equal(uri.host, "edition.cnn.com");
  equal(uri.pathname, "/.element/ssi/intl/breaking_news/3.0/banner.html");
  equal(uri.search, "?csiID=csi1");
  equal(uri.hash, "#hello");
  equal(uri.filename, "banner.html");
  equal(uri.extension, "html");
  equal(uri.dir_pathname, "/.element/ssi/intl/breaking_news/3.0/");
  equal(uri.abs_dir, "http://edition.cnn.com/.element/ssi/intl/breaking_news/3.0/");
  deepEqual(uri.params, [{key: "csiID", value: "csi1"}]);
  deepEqual(uri.path_parts, [".element", "ssi", "intl", "breaking_news", "3.0", "banner.html"]);
  equal(uri.short_distinguisher, "banner.html?csiID=csi1#hello");

  var uri = new URI("foo.txt");

  equal(uri.protocol, "");
  equal(uri.host, "");
  equal(uri.pathname, "foo.txt");
  equal(uri.search, "");
  equal(uri.hash, "");
  equal(uri.filename, "foo.txt");
  equal(uri.extension, "txt");
  equal(uri.dir_pathname, "");
  equal(uri.abs_dir, "");
  deepEqual(uri.params, []);
  deepEqual(uri.path_parts, ["foo.txt"]);
  equal(uri.short_distinguisher, "foo.txt");

  // Tests for params
  var uri = new URI("foo?one=two&one=three");
  deepEqual(uri.params, [{key: "one", value: "two"}, {key: "one", value: "three"}]);

  var uri = new URI("foo?one=two&one=&do=true");
  deepEqual(uri.params, [{key: "one", value: "two"}, {key: "one", value: ""}, {key: "do", value:"true"}]);

  var uri = new URI("foo?one=two&one&do=true");
  deepEqual(uri.params, [{key: "one", value: "two"}, {key: "one", value: ""},{key: "do", value: "true"}]);

  var uri = new URI("foo?hasOwnProperty=yup&constructor=me=true");
  deepEqual(uri.params, [{key: "hasOwnProperty", value: "yup"}, {key: "constructor", value: "me=true"}]);

  var uri = new URI("foo.txt?on?e=two&one");
  deepEqual(uri.params, [{key: "on?e", value: "two"}, {key: "one", value: ""}]);

  var uri = new URI("foo.txt?one=two&&&ne&do=true");
  deepEqual(uri.params, [{key: "one", value: "two"}, {key: "ne", value: ""}, {key: "do", value: "true"}]);

  var uri = new URI("?do=true%20%26amp;%20for_real&true%20%26amp;%20for_real=yes");
  deepEqual(uri.params, [{key: "do", value: "true &amp; for_real"}, {key: "true &amp; for_real", value: "yes"}]);

  // tests for short_distinguisher
  var uri = new URI("bar/foo?one=two&one=three#hash");
  equal(uri.short_distinguisher, "foo?one=two&one=three#hash");

  var uri = new URI("bar/foo#hash");
  equal(uri.short_distinguisher, "foo#hash");

  var uri = new URI("bar/foo?q");
  equal(uri.short_distinguisher, "foo?q");

  var uri = new URI("bar/?q");
  equal(uri.short_distinguisher, "?q");

  var uri = new URI("bar/#h1");
  equal(uri.short_distinguisher, "#h1");

  var uri = new URI("foo/bar/");
  equal(uri.short_distinguisher, "bar");
  
  var uri = new URI("data:text/html,<p>?a=b#a");
  equal(uri.protocol, "data:");
  equal(uri.host, "");
  equal(uri.pathname, "text/html,<p>?a=b");
  equal(uri.search, "");
  equal(uri.hash, "#a");
  equal(uri.filename, "");
  equal(uri.extension, "");
  equal(uri.dir_pathname, "");
  equal(uri.abs_dir, "");
  deepEqual(uri.params, []);
  deepEqual(uri.path_parts, []);
  equal(uri.short_distinguisher, "data:text/html,<p>?a=b");
});



{'fraction_non_alphanumeric': 0.2403031654034775, 'fraction_numerical': 0.008322187546440778, 'mean_word_length': 5.063063063063063, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7109833', 'n_tokens_mistral': 2702, 'n_tokens_neox': 2666, 'n_words': 462}