Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ab-test-middleware

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ab-test-middleware - npm Package Compare versions

Comparing version 0.1.5-alpha to 0.1.6-alpha

4

modules/middleware/DefaultDistributionMiddleware.js

@@ -7,3 +7,3 @@ const path = require('path');

const {
distFolder, defaultDist, distPath, entryFile, ingresses
distFolder, defaultDist, distPath, entryFile, ingresses, modifiedBaseUrl
} = req.locals;

@@ -13,3 +13,3 @@ if (!req.baseUrl || ingresses.includes(req.baseUrl)) {

}
return res.sendFile(path.join(defaultDist, req.baseUrl), { root: distPath, index: false });
return res.sendFile(path.join(defaultDist, modifiedBaseUrl), { root: distPath, index: false });
} catch (e) {

@@ -16,0 +16,0 @@ return next(e);

@@ -8,2 +8,10 @@ /* eslint-disable no-param-reassign */

const preprocessBaseUrl = (req) => {
if (!req.baseUrl) return;
let modifiedBaseUrl = req.baseUrl;
ingresses.map((i) => RegExp(`^${i}`))
.forEach((regExp) => modifiedBaseUrl = modifiedBaseUrl.replace(regExp, ''))
return modifiedBaseUrl;
}
const distributionMiddleware = (req, res, next) => {

@@ -16,2 +24,3 @@ try {

req.locals.ingresses = ingresses;
req.locals.modifiedBaseUrl = preprocessBaseUrl(req);
const filteredPaths = dists.filter((d) => d === dist && distributionToggles[d]);

@@ -22,3 +31,4 @@ if (filteredPaths.length === 1) {

}
return res.sendFile(path.join(dist, req.baseUrl), { root: distPath, index: false });
return res.sendFile(path.join(dist, req.locals.modifiedBaseUrl), { root: distPath, index: false });
}

@@ -25,0 +35,0 @@ } catch (e) {

{
"name": "ab-test-middleware",
"version": "0.1.5-alpha",
"version": "0.1.6-alpha",
"description": "An express middleware that manages multiple distributions for A/B/N testing purposes.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -6,5 +6,8 @@ # ab-test-middleware

## TL;DR
## Usage (the TL;DR version)
Assuming your distributions are built already and available in your `build` folder with the following structure:
Assuming your distributions are built already and available in your `build` folder.
I suggest using [navikt/ab-test/actions/build@v1](https://github.com/navikt/ab-test/tree/main/actions/build)
if you're running your deployments by means of GitHub Actions.
The `build` folder should be created with the following structure:
```

@@ -11,0 +14,0 @@ build/

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc