express-ext 0.2.4 → 0.2.5

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/index.js CHANGED
@@ -38,15 +38,6 @@ __export(require('./search'));
38
38
  __export(require('./search_func'));
39
39
  __export(require('./SearchController'));
40
40
  __export(require('./view'));
41
- function hasQuery(req) {
42
- return req.url.indexOf('?') >= 0;
43
- }
44
- exports.hasQuery = hasQuery;
45
- function getQuery(url) {
46
- var i = url.indexOf('?');
47
- return i < 0 ? '' : url.substring(i + 1);
48
- }
49
- exports.getQuery = getQuery;
50
41
  function allow(access) {
51
42
  var ao = access.origin;
52
43
  if (typeof ao === 'string') {
package/lib/search.js CHANGED
@@ -75,11 +75,25 @@ function removePageQuery(query, page, partialIsTrue) {
75
75
  }
76
76
  }
77
77
  exports.removePageQuery = removePageQuery;
78
+ function hasQuery(req) {
79
+ return req.url.indexOf('?') >= 0;
80
+ }
81
+ exports.hasQuery = hasQuery;
82
+ function getQuery(url) {
83
+ var i = url.indexOf('?');
84
+ return i < 0 ? '' : url.substring(i + 1);
85
+ }
86
+ exports.getQuery = getQuery;
78
87
  function buildPageQuery(query) {
79
88
  var qr = removePageQuery(query);
80
89
  return qr.length == 0 ? qr : '&' + qr;
81
90
  }
82
91
  exports.buildPageQuery = buildPageQuery;
92
+ function buildPageQueryFromUrl(url) {
93
+ var query = getQuery(url);
94
+ return buildPageQuery(query);
95
+ }
96
+ exports.buildPageQueryFromUrl = buildPageQueryFromUrl;
83
97
  function jsonResult(res, result, quick, fields, config) {
84
98
  if (quick && fields && fields.length > 0) {
85
99
  res.status(200).json(toCsv(fields, result)).end();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-ext",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "express-ext",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -40,14 +40,6 @@ export * from './search_func';
40
40
  export * from './SearchController';
41
41
  export * from './view';
42
42
 
43
- export function hasQuery(req: Request): boolean {
44
- return req.url.indexOf('?') >= 0;
45
- }
46
- export function getQuery(url: string): string {
47
- const i = url.indexOf('?');
48
- return i < 0 ? '' : url.substring(i + 1);
49
- }
50
-
51
43
  export interface AccessConfig {
52
44
  origin?: string | string[];
53
45
  credentials?: string | string[];
package/src/search.ts CHANGED
@@ -99,10 +99,21 @@ export function removePageQuery(query: string, page?: string, partialIsTrue?: st
99
99
  return query.replace(pageQuery, '');
100
100
  }
101
101
  }
102
+ export function hasQuery(req: Request): boolean {
103
+ return req.url.indexOf('?') >= 0;
104
+ }
105
+ export function getQuery(url: string): string {
106
+ const i = url.indexOf('?');
107
+ return i < 0 ? '' : url.substring(i + 1);
108
+ }
102
109
  export function buildPageQuery(query: string): string {
103
110
  const qr = removePageQuery(query);
104
111
  return qr.length == 0 ? qr : '&' + qr;
105
112
  }
113
+ export function buildPageQueryFromUrl(url: string): string {
114
+ const query = getQuery(url);
115
+ return buildPageQuery(query);
116
+ }
106
117
 
107
118
  export function jsonResult<T>(res: Response, result: SearchResult<T>, quick?: boolean, fields?: string[], config?: SearchConfig): void {
108
119
  if (quick && fields && fields.length > 0) {