found problem with unit test of baseUri function, makes code much simpler
This commit is contained in:
parent
fb99d5bb93
commit
b6d8d0f250
|
@ -276,21 +276,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
||||||
return baseUri;
|
return baseUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
// window.baseURI isn't emulated by JSdom
|
baseUri = window.location.origin + window.location.pathname;
|
||||||
var loc = window.location;
|
|
||||||
baseUri = loc.href.substring(
|
|
||||||
0,
|
|
||||||
loc.href.length - loc.search.length - loc.hash.length
|
|
||||||
);
|
|
||||||
|
|
||||||
// if base uri contains query string (when no base tag is present),
|
|
||||||
// it is unwanted
|
|
||||||
var queryIndex = baseUri.indexOf('?');
|
|
||||||
if (queryIndex !== -1) {
|
|
||||||
// so we built our own baseuri
|
|
||||||
baseUri = baseUri.substring(0, queryIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
return baseUri;
|
return baseUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,9 @@ var jsc = require('jsverify'),
|
||||||
a2zString.map(function(c) {
|
a2zString.map(function(c) {
|
||||||
return c.toUpperCase();
|
return c.toUpperCase();
|
||||||
})
|
})
|
||||||
);
|
),
|
||||||
|
// schemas supported by the whatwg-url library
|
||||||
|
schemas = ['ftp','gopher','http','https','ws','wss'];
|
||||||
|
|
||||||
global.$ = global.jQuery = require('./jquery-3.1.1');
|
global.$ = global.jQuery = require('./jquery-3.1.1');
|
||||||
global.sjcl = require('./sjcl-1.0.6');
|
global.sjcl = require('./sjcl-1.0.6');
|
||||||
|
@ -73,12 +75,12 @@ describe('Helper', function () {
|
||||||
|
|
||||||
jsc.property(
|
jsc.property(
|
||||||
'returns the URL without query & fragment',
|
'returns the URL without query & fragment',
|
||||||
jsc.nearray(jsc.elements(a2zString)),
|
jsc.elements(schemas),
|
||||||
jsc.nearray(jsc.elements(a2zString)),
|
jsc.nearray(jsc.elements(a2zString)),
|
||||||
jsc.array(jsc.elements(queryString)),
|
jsc.array(jsc.elements(queryString)),
|
||||||
'string',
|
'string',
|
||||||
function (schema, address, query, fragment) {
|
function (schema, address, query, fragment) {
|
||||||
var expected = schema.join('') + '://' + address.join('') + '/',
|
var expected = schema + '://' + address.join('') + '/',
|
||||||
clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment}),
|
clean = jsdom('', {url: expected + '?' + query.join('') + '#' + fragment}),
|
||||||
result = $.PrivateBin.Helper.baseUri();
|
result = $.PrivateBin.Helper.baseUri();
|
||||||
$.PrivateBin.Helper.reset();
|
$.PrivateBin.Helper.reset();
|
||||||
|
|
|
@ -69,7 +69,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-BqQUrn7gw41w/GPvE28nN9ANnl59EAuo0xdcfzSIkw/b/SzT7WF0PS1SNs4hSc6hU6S1eJzS8qjgOI+8qt//RQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-rvc7nkZjk/ntvq0byTiVQX6lP+vXkg0TwZ+LLd7EpeV+7Rr2hm/bUwOrc77t1JkIicywjvfu6tKYBWVkjuCHNw==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
|
@ -47,7 +47,7 @@ if ($MARKDOWN):
|
||||||
<?php
|
<?php
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-BqQUrn7gw41w/GPvE28nN9ANnl59EAuo0xdcfzSIkw/b/SzT7WF0PS1SNs4hSc6hU6S1eJzS8qjgOI+8qt//RQ==" crossorigin="anonymous"></script>
|
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-rvc7nkZjk/ntvq0byTiVQX6lP+vXkg0TwZ+LLd7EpeV+7Rr2hm/bUwOrc77t1JkIicywjvfu6tKYBWVkjuCHNw==" crossorigin="anonymous"></script>
|
||||||
<!--[if lt IE 10]>
|
<!--[if lt IE 10]>
|
||||||
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
Loading…
Reference in New Issue