@webqit/webflo 0.20.9 → 0.20.11-next.0

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/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "vanila-javascript"
13
13
  ],
14
14
  "homepage": "https://webqit.io/tooling/webflo",
15
- "version": "0.20.9",
15
+ "version": "0.20.11-next.0",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -140,18 +140,36 @@ export const response = {
140
140
  return instance;
141
141
  }
142
142
  },
143
+ redirect: {
144
+ value: function (url, status = 302) {
145
+ if (typeof url !== 'string' && !(url instanceof URL)) {
146
+ throw new Error('Redirect URL must be a string or URL!');
147
+ }
148
+ if (typeof status !== 'number') {
149
+ throw new Error('Redirect code must be a number!');
150
+ }
151
+ return new Response(null, { status, headers: { Location: url } });
152
+ }
153
+ },
143
154
  redirectWith: {
144
- value: function (url, { status = 302, request = null, response = null }) {
145
- if (typeof status !== 'string') {
146
- throw new Error('Redirect code must be an object!');
155
+ value: function (url, ...args) {
156
+ if (typeof url !== 'string' && !(url instanceof URL)) {
157
+ throw new Error('Redirect URL must be a string or URL!');
158
+ }
159
+ let status = 302;
160
+ if (!_isObject(args[0])) {
161
+ status = args.shift();
147
162
  }
148
- if (request && !_isObject(request) || response && !_isObject(response)) {
149
- throw new Error('Carries (redirect requests and responses) must be an object!');
163
+ if (typeof status !== 'number') {
164
+ throw new Error('Redirect code must be a number!');
150
165
  }
151
- const responseInstance = this.redirect(url, status);
152
- if (request || response) {
166
+ if (args.some((arg) => !_isObject(arg))) {
167
+ throw new Error('Redirect arguments must be objects!');
168
+ }
169
+ const responseInstance = new Response(null, { status, headers: { Location: url } });
170
+ if (args.length) {
153
171
  const responseMeta = _wq(responseInstance, 'meta');
154
- responseMeta.set('carry', { request, response });
172
+ responseMeta.set('carry', args);
155
173
  }
156
174
  return responseInstance;
157
175
  }
@@ -436,12 +454,5 @@ export function renderCookieObjToString(cookieObj) {
436
454
  if (_attrName === 'MaxAge') { _attrName = 'Max-Age' };
437
455
  attrsArr.push(cookieObj[attrName] === true ? _attrName : `${_attrName}=${cookieObj[attrName]}`);
438
456
  }
439
- return attrsArr.join(';');
440
- }
441
-
442
- // ----- shim
443
-
444
- const importUrl = new URL(import.meta.url);
445
- if (importUrl.searchParams.has('shim')) {
446
- shim(importUrl.searchParams.get('shim')?.trim());
447
- }
457
+ return attrsArr.join('; ');
458
+ }
@@ -1,4 +1,5 @@
1
1
  import { _isObject } from '@webqit/util/js/index.js';
2
+ import { _even } from '@webqit/util/obj/index.js';
2
3
  import { renderCookieObjToString } from '../webflo-fetch/index.js';
3
4
  import { HttpState } from './HttpState.js';
4
5