url-lib
Version:
A simple, lightweight string utility for Node and browsers that supports serializing and parsing URLs and query strings.
28 lines (23 loc) • 878 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
// Adapted from the Uize.Url module, a part of the UIZE JavaScript Framework.
var cacheDefeatStrCallCount = 0;
/**
* Returns a string value (generated using the time and a random number)
* that can be used as a query parameter value to cause a URL to be
* unique in order to defeat caching.
* @returns {string} Cache defeat string
*/
var getCacheDefeatStr = function getCacheDefeatStr() {
// Three pieces of randomness:
// current timestamp
var timestamp = Date.now(); // random number between 1-1000
var randomNum = Math.round(Math.random() * 1000); // continuously incrementing counter
var counter = cacheDefeatStrCallCount++;
return "".concat(timestamp).concat(randomNum).concat(counter);
};
var _default = getCacheDefeatStr;
exports.default = _default;