mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2024-03-22 13:10:41 +08:00
refactor URL generators
This commit is contained in:
parent
d493ba7337
commit
fd82b937a9
|
@ -80,7 +80,7 @@ describe('Model', function () {
|
||||||
|
|
||||||
jsc.property(
|
jsc.property(
|
||||||
'returns the query string without separator, if any',
|
'returns the query string without separator, if any',
|
||||||
common.jscUrl(),
|
common.jscUrl(true, false),
|
||||||
jsc.tuple(new Array(16).fill(common.jscHexString)),
|
jsc.tuple(new Array(16).fill(common.jscHexString)),
|
||||||
jsc.array(common.jscQueryString()),
|
jsc.array(common.jscQueryString()),
|
||||||
jsc.array(common.jscQueryString()),
|
jsc.array(common.jscQueryString()),
|
||||||
|
@ -184,7 +184,7 @@ describe('Model', function () {
|
||||||
);
|
);
|
||||||
jsc.property(
|
jsc.property(
|
||||||
'throws exception on empty fragment of the URL',
|
'throws exception on empty fragment of the URL',
|
||||||
common.jscUrl(false, false),
|
common.jscUrl(false),
|
||||||
function (url) {
|
function (url) {
|
||||||
let clean = jsdom('', {url: common.urlToString(url)}),
|
let clean = jsdom('', {url: common.urlToString(url)}),
|
||||||
result = false;
|
result = false;
|
||||||
|
|
|
@ -13,10 +13,9 @@ describe('UiHelper', function () {
|
||||||
|
|
||||||
jsc.property(
|
jsc.property(
|
||||||
'redirects to home, when the state is null',
|
'redirects to home, when the state is null',
|
||||||
common.jscSchemas(),
|
common.jscUrl(false, false),
|
||||||
jsc.nearray(common.jscA2zString()),
|
function (url) {
|
||||||
function (schema, address) {
|
const expected = common.urlToString(url),
|
||||||
var expected = schema + '://' + address.join('') + '/',
|
|
||||||
clean = jsdom('', {url: expected});
|
clean = jsdom('', {url: expected});
|
||||||
|
|
||||||
// make window.location.href writable
|
// make window.location.href writable
|
||||||
|
@ -34,13 +33,11 @@ describe('UiHelper', function () {
|
||||||
|
|
||||||
jsc.property(
|
jsc.property(
|
||||||
'does not redirect to home, when a new paste is created',
|
'does not redirect to home, when a new paste is created',
|
||||||
common.jscSchemas(),
|
common.jscUrl(false),
|
||||||
jsc.nearray(common.jscA2zString()),
|
|
||||||
jsc.array(common.jscQueryString()),
|
|
||||||
jsc.nearray(common.jscBase64String()),
|
jsc.nearray(common.jscBase64String()),
|
||||||
function (schema, address, query, fragment) {
|
function (url, fragment) {
|
||||||
var expected = schema + '://' + address.join('') + '/?' +
|
url.fragment = fragment.join('');
|
||||||
query.join('') + '#' + fragment.join(''),
|
const expected = common.urlToString(url),
|
||||||
clean = jsdom('', {url: expected});
|
clean = jsdom('', {url: expected});
|
||||||
|
|
||||||
// make window.location.href writable
|
// make window.location.href writable
|
||||||
|
@ -67,15 +64,12 @@ describe('UiHelper', function () {
|
||||||
|
|
||||||
jsc.property(
|
jsc.property(
|
||||||
'redirects to home',
|
'redirects to home',
|
||||||
common.jscSchemas(),
|
common.jscUrl(),
|
||||||
jsc.nearray(common.jscA2zString()),
|
function (url) {
|
||||||
jsc.array(common.jscQueryString()),
|
const clean = jsdom('', {url: common.urlToString(url)});
|
||||||
jsc.nearray(common.jscBase64String()),
|
delete(url.query);
|
||||||
function (schema, address, query, fragment) {
|
delete(url.fragment);
|
||||||
var expected = schema + '://' + address.join('') + '/',
|
const expected = common.urlToString(url);
|
||||||
clean = jsdom('', {
|
|
||||||
url: expected + '?' + query.join('') + '#' + fragment.join('')
|
|
||||||
});
|
|
||||||
|
|
||||||
// make window.location.href writable
|
// make window.location.href writable
|
||||||
Object.defineProperty(window.location, 'href', {
|
Object.defineProperty(window.location, 'href', {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user