@abtnode/router-provider 1.16.29-beta-cbfd116d → 1.16.29-beta-8671c2cf

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.
@@ -56,7 +56,7 @@ const createRequestHandler = (id) => (req, res, target) => {
56
56
  const parsed = url.parse(req.url);
57
57
  if (parsed.pathname === rule.prefix) {
58
58
  logger.info('redirect url', { url: req.url, rule });
59
- parsed.pathname = joinURL(rule.prefix, '/');
59
+ parsed.pathname = rule.prefix.endsWith('/') ? rule.prefix : `${rule.prefix}/`;
60
60
  res.writeHead(307, { Location: url.format(parsed) });
61
61
  res.end();
62
62
  return { abort: true };
package/lib/util.js CHANGED
@@ -162,17 +162,18 @@ const toSlotDomain = (domain) => {
162
162
 
163
163
  const findRule = (rules, url) =>
164
164
  rules.find((x) => {
165
+ const [pathname] = url.split('?');
165
166
  const { prefix, suffix = '' } = x;
166
167
  if (suffix) {
167
168
  const regex = new RegExp(`${suffix}$`);
168
- return url.startsWith(prefix) && regex.test(url);
169
+ return pathname.startsWith(prefix) && regex.test(pathname);
169
170
  }
170
171
 
171
- if (prefix === '/' && prefix === url) {
172
+ if (prefix === '/' && prefix === pathname) {
172
173
  return true;
173
174
  }
174
175
 
175
- return url.startsWith(prefix);
176
+ return pathname.startsWith(prefix);
176
177
  });
177
178
  const matchRule = (rules, url) => {
178
179
  const rulesWithSuffix = rules.filter((x) => x.suffix);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abtnode/router-provider",
3
- "version": "1.16.29-beta-cbfd116d",
3
+ "version": "1.16.29-beta-8671c2cf",
4
4
  "description": "Routing engine implementations for abt node",
5
5
  "author": "polunzh <polunzh@gmail.com>",
6
6
  "homepage": "https://github.com/ArcBlock/blocklet-server#readme",
@@ -32,10 +32,10 @@
32
32
  "url": "https://github.com/ArcBlock/blocklet-server/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@abtnode/constant": "1.16.29-beta-cbfd116d",
36
- "@abtnode/logger": "1.16.29-beta-cbfd116d",
37
- "@abtnode/router-templates": "1.16.29-beta-cbfd116d",
38
- "@abtnode/util": "1.16.29-beta-cbfd116d",
35
+ "@abtnode/constant": "1.16.29-beta-8671c2cf",
36
+ "@abtnode/logger": "1.16.29-beta-8671c2cf",
37
+ "@abtnode/router-templates": "1.16.29-beta-8671c2cf",
38
+ "@abtnode/util": "1.16.29-beta-8671c2cf",
39
39
  "@arcblock/http-proxy": "^1.19.1",
40
40
  "@arcblock/is-valid-domain": "^1.0.5",
41
41
  "axios": "^1.7.2",
@@ -59,5 +59,5 @@
59
59
  "bluebird": "^3.7.2",
60
60
  "fs-extra": "^11.2.0"
61
61
  },
62
- "gitHead": "e9bdb7af77f2d126e40195c67972b07fe683adf9"
62
+ "gitHead": "67207cc32f2cdf4ab8af39d4083ad61fba9711e2"
63
63
  }