@browserless.io/browserless 2.38.0 → 2.38.1

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.
@@ -299,7 +299,12 @@ export class BrowserManager {
299
299
  // Handle browser re-connects here
300
300
  if (this.reconnectionPatterns.some((p) => req.parsed.pathname.includes(p))) {
301
301
  const sessions = Array.from(this.browsers);
302
- const id = req.parsed.pathname.split('/').pop();
302
+ const pathParts = req.parsed.pathname.split('/');
303
+ // The last part of the path is the browser ID, or the second last part in case the path ends with "/"
304
+ const id = pathParts.pop() || pathParts.pop();
305
+ if (!id) {
306
+ throw new NotFound(`Couldn't locate browser ID from path "${req.parsed.pathname}"`);
307
+ }
303
308
  const found = sessions.find(([b]) => b.wsEndpoint()?.includes(id));
304
309
  if (found) {
305
310
  const [browser, session] = found;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browserless.io/browserless",
3
- "version": "2.38.0",
3
+ "version": "2.38.1",
4
4
  "license": "SSPL",
5
5
  "description": "The browserless platform",
6
6
  "author": "browserless.io",
@@ -466,7 +466,14 @@ export class BrowserManager {
466
466
  this.reconnectionPatterns.some((p) => req.parsed.pathname.includes(p))
467
467
  ) {
468
468
  const sessions = Array.from(this.browsers);
469
- const id = req.parsed.pathname.split('/').pop() as string;
469
+ const pathParts = req.parsed.pathname.split('/');
470
+ // The last part of the path is the browser ID, or the second last part in case the path ends with "/"
471
+ const id = pathParts.pop() as string || pathParts.pop() as string;
472
+ if (!id) {
473
+ throw new NotFound(
474
+ `Couldn't locate browser ID from path "${req.parsed.pathname}"`,
475
+ );
476
+ }
470
477
  const found = sessions.find(([b]) => b.wsEndpoint()?.includes(id));
471
478
 
472
479
  if (found) {
@@ -984,7 +984,7 @@
984
984
  },
985
985
  "info": {
986
986
  "title": "Browserless",
987
- "version": "2.38.0",
987
+ "version": "2.38.1",
988
988
  "x-logo": {
989
989
  "altText": "browserless logo",
990
990
  "url": "./docs/browserless-logo-inline.svg"
@@ -984,7 +984,7 @@
984
984
  },
985
985
  "info": {
986
986
  "title": "Browserless",
987
- "version": "2.38.0",
987
+ "version": "2.38.1",
988
988
  "x-logo": {
989
989
  "altText": "browserless logo",
990
990
  "url": "./docs/browserless-logo-inline.svg"