react-hook-core 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/search.js CHANGED
@@ -410,10 +410,10 @@ function getPrefix(url) {
410
410
  function addParametersIntoUrl(ft, isFirstLoad, page, fields, limit) {
411
411
  if (!isFirstLoad) {
412
412
  if (!fields || fields.length === 0) {
413
- fields = 'fields';
413
+ fields = "fields";
414
414
  }
415
415
  if (!limit || limit.length === 0) {
416
- limit = 'limit';
416
+ limit = "limit";
417
417
  }
418
418
  if (page && page > 1) {
419
419
  if (!ft.page || ft.page <= 1) {
@@ -432,7 +432,7 @@ function addParametersIntoUrl(ft, isFirstLoad, page, fields, limit) {
432
432
  var objValue = ft[key];
433
433
  if (objValue) {
434
434
  if (key !== fields) {
435
- if (typeof objValue === 'string' || typeof objValue === 'number') {
435
+ if (typeof objValue === "string" || typeof objValue === "number") {
436
436
  if (key === limit) {
437
437
  if (objValue !== core_1.resources.limit) {
438
438
  url += getPrefix(url) + (key + "=" + objValue);
@@ -442,7 +442,7 @@ function addParametersIntoUrl(ft, isFirstLoad, page, fields, limit) {
442
442
  url += getPrefix(url) + (key + "=" + objValue);
443
443
  }
444
444
  }
445
- else if (typeof objValue === 'object') {
445
+ else if (typeof objValue === "object") {
446
446
  if (objValue instanceof Date) {
447
447
  url += getPrefix(url) + (key + "=" + objValue.toISOString());
448
448
  }
@@ -452,14 +452,14 @@ function addParametersIntoUrl(ft, isFirstLoad, page, fields, limit) {
452
452
  var strs = [];
453
453
  for (var _a = 0, objValue_1 = objValue; _a < objValue_1.length; _a++) {
454
454
  var subValue = objValue_1[_a];
455
- if (typeof subValue === 'string') {
455
+ if (typeof subValue === "string") {
456
456
  strs.push(subValue);
457
457
  }
458
- else if (typeof subValue === 'number') {
458
+ else if (typeof subValue === "number") {
459
459
  strs.push(subValue.toString());
460
460
  }
461
461
  }
462
- url += getPrefix(url) + (key + "=" + strs.join(','));
462
+ url += getPrefix(url) + (key + "=" + strs.join(","));
463
463
  }
464
464
  }
465
465
  else {
@@ -467,11 +467,13 @@ function addParametersIntoUrl(ft, isFirstLoad, page, fields, limit) {
467
467
  for (var _b = 0, keysLvl2_1 = keysLvl2; _b < keysLvl2_1.length; _b++) {
468
468
  var key2 = keysLvl2_1[_b];
469
469
  var objValueLvl2 = objValue[key2];
470
- if (objValueLvl2 instanceof Date) {
471
- url += getPrefix(url) + (key + "." + key2 + "=" + objValueLvl2.toISOString());
472
- }
473
- else {
474
- url += getPrefix(url) + (key + "." + key2 + "=" + objValueLvl2);
470
+ if (objValueLvl2) {
471
+ if (objValueLvl2 instanceof Date) {
472
+ url += getPrefix(url) + (key + "." + key2 + "=" + objValueLvl2.toISOString());
473
+ }
474
+ else {
475
+ url += getPrefix(url) + (key + "." + key2 + "=" + objValueLvl2);
476
+ }
475
477
  }
476
478
  }
477
479
  }
@@ -480,15 +482,15 @@ function addParametersIntoUrl(ft, isFirstLoad, page, fields, limit) {
480
482
  }
481
483
  }
482
484
  }
483
- var p = 'http://';
485
+ var p = "http://";
484
486
  var loc = window.location.href;
485
487
  if (loc.length >= 8) {
486
488
  var ss = loc.substring(0, 8);
487
- if (ss === 'https://') {
488
- p = 'https://';
489
+ if (ss === "https://") {
490
+ p = "https://";
489
491
  }
490
492
  }
491
- window.history.replaceState({ path: currentUrl }, '', p + url);
493
+ window.history.replaceState({ path: currentUrl }, "", p + url);
492
494
  }
493
495
  }
494
496
  exports.addParametersIntoUrl = addParametersIntoUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-hook-core",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "react",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/search.ts CHANGED
@@ -414,59 +414,61 @@ function getPrefix(url: string): string {
414
414
  export function addParametersIntoUrl<S extends Filter>(ft: S, isFirstLoad?: boolean, page?: number, fields?: string, limit?: string): void {
415
415
  if (!isFirstLoad) {
416
416
  if (!fields || fields.length === 0) {
417
- fields = 'fields';
417
+ fields = "fields"
418
418
  }
419
419
  if (!limit || limit.length === 0) {
420
- limit = 'limit';
420
+ limit = "limit"
421
421
  }
422
422
  if (page && page > 1) {
423
423
  if (!ft.page || ft.page <= 1) {
424
- ft.page = page;
424
+ ft.page = page
425
425
  }
426
426
  }
427
- const pageIndex = ft.page;
427
+ const pageIndex = ft.page
428
428
  if (pageIndex && !isNaN(pageIndex) && pageIndex <= 1) {
429
- delete ft.page;
429
+ delete ft.page
430
430
  }
431
- const keys = Object.keys(ft);
432
- const currentUrl = window.location.host + window.location.pathname;
433
- let url = removeFormatUrl(currentUrl);
431
+ const keys = Object.keys(ft)
432
+ const currentUrl = window.location.host + window.location.pathname
433
+ let url = removeFormatUrl(currentUrl)
434
434
  for (const key of keys) {
435
- const objValue = (ft as any)[key];
435
+ const objValue = (ft as any)[key]
436
436
  if (objValue) {
437
437
  if (key !== fields) {
438
- if (typeof objValue === 'string' || typeof objValue === 'number') {
438
+ if (typeof objValue === "string" || typeof objValue === "number") {
439
439
  if (key === limit) {
440
440
  if (objValue !== resources.limit) {
441
- url += getPrefix(url) + `${key}=${objValue}`;
441
+ url += getPrefix(url) + `${key}=${objValue}`
442
442
  }
443
443
  } else {
444
- url += getPrefix(url) + `${key}=${objValue}`;
444
+ url += getPrefix(url) + `${key}=${objValue}`
445
445
  }
446
- } else if (typeof objValue === 'object') {
446
+ } else if (typeof objValue === "object") {
447
447
  if (objValue instanceof Date) {
448
- url += getPrefix(url) + `${key}=${objValue.toISOString()}`;
448
+ url += getPrefix(url) + `${key}=${objValue.toISOString()}`
449
449
  } else {
450
450
  if (Array.isArray(objValue)) {
451
451
  if (objValue.length > 0) {
452
- const strs: string[] = [];
452
+ const strs: string[] = []
453
453
  for (const subValue of objValue) {
454
- if (typeof subValue === 'string') {
455
- strs.push(subValue);
456
- } else if (typeof subValue === 'number') {
457
- strs.push(subValue.toString());
454
+ if (typeof subValue === "string") {
455
+ strs.push(subValue)
456
+ } else if (typeof subValue === "number") {
457
+ strs.push(subValue.toString())
458
458
  }
459
459
  }
460
- url += getPrefix(url) + `${key}=${strs.join(',')}`;
460
+ url += getPrefix(url) + `${key}=${strs.join(",")}`
461
461
  }
462
462
  } else {
463
- const keysLvl2 = Object.keys(objValue);
463
+ const keysLvl2 = Object.keys(objValue)
464
464
  for (const key2 of keysLvl2) {
465
- const objValueLvl2 = objValue[key2];
466
- if (objValueLvl2 instanceof Date) {
467
- url += getPrefix(url) + `${key}.${key2}=${objValueLvl2.toISOString()}`;
468
- } else {
469
- url += getPrefix(url) + `${key}.${key2}=${objValueLvl2}`;
465
+ const objValueLvl2 = objValue[key2]
466
+ if (objValueLvl2) {
467
+ if (objValueLvl2 instanceof Date) {
468
+ url += getPrefix(url) + `${key}.${key2}=${objValueLvl2.toISOString()}`
469
+ } else {
470
+ url += getPrefix(url) + `${key}.${key2}=${objValueLvl2}`
471
+ }
470
472
  }
471
473
  }
472
474
  }
@@ -475,15 +477,15 @@ export function addParametersIntoUrl<S extends Filter>(ft: S, isFirstLoad?: bool
475
477
  }
476
478
  }
477
479
  }
478
- let p = 'http://';
479
- const loc = window.location.href;
480
+ let p = "http://"
481
+ const loc = window.location.href
480
482
  if (loc.length >= 8) {
481
- const ss = loc.substring(0, 8);
482
- if (ss === 'https://') {
483
- p = 'https://';
483
+ const ss = loc.substring(0, 8)
484
+ if (ss === "https://") {
485
+ p = "https://"
484
486
  }
485
487
  }
486
- window.history.replaceState({path: currentUrl}, '', p + url);
488
+ window.history.replaceState({ path: currentUrl }, "", p + url)
487
489
  }
488
490
  }
489
491