@tinypudding/puddy-lib
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -1,35 +0,5 @@ | ||
// Get JSON From URL | ||
const getJsonFromUrl = function (url) { | ||
if (!url) url = location.href; | ||
var question = url.indexOf("?"); | ||
var hash = url.indexOf("#"); | ||
if (hash === -1 && question === -1) return {}; | ||
if (hash === -1) hash = url.length; | ||
var query = question === -1 || hash === question + 1 ? url.substring(hash) : | ||
url.substring(question + 1, hash); | ||
var result = {}; | ||
query.split("&").forEach((part) => { | ||
if (!part) return; | ||
part = part.split("+").join(" "); // replace every + with space, regexp-free version | ||
var eq = part.indexOf("="); | ||
var key = eq > -1 ? part.substr(0, eq) : part; | ||
var val = eq > -1 ? decodeURIComponent(part.substr(eq + 1)) : ""; | ||
var from = key.indexOf("["); | ||
if (from === -1) result[decodeURIComponent(key)] = val; | ||
else { | ||
var to = key.indexOf("]", from); | ||
var index = decodeURIComponent(key.substring(from + 1, to)); | ||
key = decodeURIComponent(key.substring(0, from)); | ||
if (!result[key]) result[key] = []; | ||
if (!index) result[key].push(val); | ||
else result[key][index] = val; | ||
} | ||
}); | ||
return result; | ||
}; | ||
module.exports = function (query, page, total, url = '', extraClass = '', extraClass2 = '') { | ||
if (url) { | ||
const params = getJsonFromUrl(url); | ||
const params = require('../get/queryUrlJSON')(url); | ||
if (Object.keys(params).length > 0) { | ||
@@ -36,0 +6,0 @@ if (params.page) { |
@@ -49,7 +49,8 @@ // Modules | ||
// Get URL Parameter by Name | ||
'getURLParameterByName': require('./http/getParameterByName'), | ||
// Get URL Parameter | ||
'getQueryUrlByName': require('./get/queryUrlByName'), | ||
'getQueryUrlJSON': require('./get/queryUrlJSON'), | ||
// Percentage | ||
'percentage': require('./get/percentage'), | ||
'percentage': require('./libs/percentage'), | ||
@@ -56,0 +57,0 @@ // Fetch |
{ | ||
"name": "@tinypudding/puddy-lib", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"description": "Essential codes to run the other repositories from the Tiny Pudding Account.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60029
31
797