mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2025-05-02 14:36:08 -04:00
Merge branch 'master' into jsrefactor and fixing baseUri unit test
This commit is contained in:
commit
fb99d5bb93
13 changed files with 195 additions and 51 deletions
|
@ -36,11 +36,9 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
/**
|
||||
* static Helper methods
|
||||
*
|
||||
* @param {object} window
|
||||
* @param {object} document
|
||||
* @class
|
||||
*/
|
||||
var Helper = (function (window, document) {
|
||||
var Helper = (function () {
|
||||
var me = {};
|
||||
|
||||
/**
|
||||
|
@ -278,14 +276,19 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
return baseUri;
|
||||
}
|
||||
|
||||
// get official base uri string, from base tag in head of HTML
|
||||
baseUri = document.baseURI;
|
||||
// window.baseURI isn't emulated by JSdom
|
||||
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
|
||||
if (baseUri.indexOf('?')) {
|
||||
var queryIndex = baseUri.indexOf('?');
|
||||
if (queryIndex !== -1) {
|
||||
// so we built our own baseuri
|
||||
baseUri = window.location.origin + window.location.pathname;
|
||||
baseUri = baseUri.substring(0, queryIndex);
|
||||
}
|
||||
|
||||
return baseUri;
|
||||
|
@ -307,8 +310,19 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* resets state, used for unit testing
|
||||
*
|
||||
* @name Model.reset
|
||||
* @function
|
||||
*/
|
||||
me.reset = function()
|
||||
{
|
||||
baseUri = null;
|
||||
}
|
||||
|
||||
return me;
|
||||
})(window, document);
|
||||
})();
|
||||
|
||||
/**
|
||||
* internationalization module
|
||||
|
@ -336,7 +350,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
* @prop {string[]}
|
||||
* @readonly
|
||||
*/
|
||||
var supportedLanguages = ['de', 'es', 'fr', 'it', 'no', 'pl', 'oc', 'ru', 'sl', 'zh'];
|
||||
var supportedLanguages = ['de', 'es', 'fr', 'it', 'no', 'pl', 'pt', 'oc', 'ru', 'sl', 'zh'];
|
||||
|
||||
/**
|
||||
* built in language
|
||||
|
@ -491,7 +505,7 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
|
|||
return (n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2));
|
||||
case 'sl':
|
||||
return (n % 100 === 1 ? 1 : (n % 100 === 2 ? 2 : (n % 100 === 3 || n % 100 === 4 ? 3 : 0)));
|
||||
// de, en, es, it, no
|
||||
// de, en, es, it, no, pt
|
||||
default:
|
||||
return (n !== 1 ? 1 : 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue