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

@fastly/compute-js-static-publish

Package Overview
Dependencies
Maintainers
3
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastly/compute-js-static-publish - npm Package Compare versions

Comparing version 2.4.1 to 2.4.2

2

package.json
{
"name": "@fastly/compute-js-static-publish",
"type": "module",
"version": "2.4.1",
"version": "2.4.2",
"description": "Static Publisher for Compute@Edge JavaScript",

@@ -6,0 +6,0 @@ "main": "./build/index.js",

@@ -53,12 +53,12 @@ # Static Publisher for JavaScript on Compute@Edge

| Option | Default | Description |
|------------------|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `preset` | (None) | Apply default options from a specified preset. See ["Frameworks and Static Site Generators"](#usage-with-frameworks-and-static-site-generators). |
| `output` | `./compute-js` | The directory in which to create the Compute@Edge application. |
| `public-dir` | (None) | **Required**. The root of the directory that contains your website's public files. Files at this path will be served by the generated Compute@Edge application. |
| `static-dir` | (None) | A subdirectory of `--public-dir` that contains the website's static assets. Files at this path will be cached by the browser for 1 year. Use versioned or hashed filenames to avoid serving stale assets. |
| `auto-index` | `index.html,index.htm` | Handle request paths that end in `/` by appending these names (comma-separated), in the specified order. By default, if `/path/to/a/` is requested, attempt to serve `/path/to/a/index.html`, then `/path/to/a/index.htm`. |
| `auto-ext` | `.html,.htm` | Handle request paths that do not end in `/` by appending these extensions (comma-separated), in the specified order. By default, if `/path/to/a` is requested, attempt to serve `/path/to/a`, `/path/to/a.html`, then `/path/to/a.htm`. |
| `spa` | (None) | Serve this file when the request path does not match known paths – with a `200` status code. Useful for apps that use [client-side routing](https://create-react-app.dev/docs/deployment#serving-apps-with-client-side-routing). |
| `not-found-page` | `<public-dir>/404.html` | Serve this file when the request path does not match known paths – with a `404` status code. Useful for a custom 404 error page. |
| Option | Default | Description |
|------------------|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `preset` | (None) | Apply default options from a specified preset. See ["Frameworks and Static Site Generators"](#usage-with-frameworks-and-static-site-generators). |
| `output` | `./compute-js` | The directory in which to create the Compute@Edge application. |
| `public-dir` | (None) | **Required**. The root of the directory that contains your website's public files. Files at this path will be served by the generated Compute@Edge application. |
| `static-dir` | (None) | A subdirectory of `--public-dir` that contains the website's static assets. Files at this path will be cached by the browser for 1 year. Use versioned or hashed filenames to avoid serving stale assets. |
| `auto-index` | `index.html,index.htm` | Attempt to handle request paths by appending these names (comma-separated), in the specified order. If a path does not end in a slash, a slash is added automatically. By default, if `/path/to/a/` is requested, attempt to serve `/path/to/a/index.html`, then `/path/to/a/index.htm`. |
| `auto-ext` | `.html,.htm` | Handle request paths that do not end in `/` by appending these extensions (comma-separated), in the specified order. By default, if `/path/to/a` is requested, attempt to serve `/path/to/a`, `/path/to/a.html`, then `/path/to/a.htm`. |
| `spa` | (None) | Serve this file when the request path does not match known paths – with a `200` status code. Useful for apps that use [client-side routing](https://create-react-app.dev/docs/deployment#serving-apps-with-client-side-routing). |
| `not-found-page` | `<public-dir>/404.html` | Serve this file when the request path does not match known paths – with a `404` status code. Useful for a custom 404 error page. |

@@ -65,0 +65,0 @@ On subsequent builds of your Compute@Edge application, `compute-js-static-publish` will run with a special flag, `build-static`, reading from stored configuration, then scanning the `--public-dir` directory to recreate `./src/statics.js`.

@@ -9,6 +9,5 @@ /// <reference types="@fastly/js-compute" />

function getMatchingRequestPath(path) {
// If the path being looked up does not end in a slash, it has to
// match exactly one of the assets
if(!path.endsWith('/')) {
// A path that does not end in a slash can match an asset directly
if (staticAssets.getAsset(path) != null) {

@@ -18,3 +17,4 @@ return path;

// try auto-ext
// ... or, we can try auto-ext:
// looks for an asset that has the specified suffix (usually extension, such as .html)
if(autoExt != null) {

@@ -28,11 +28,16 @@ for (const extEntry of autoExt) {

}
}
return null;
// try auto-index:
// treats the path as a directory, and looks for an asset with the specified
// suffix (usually an index file, such as index.html)
let dir = path;
// remove all slashes from end, and add one trailing slash
while(dir.endsWith('/')) {
dir = dir.slice(0, -1);
}
// try auto-index
dir = dir + '/';
if(autoIndex != null) {
for (const indexEntry of autoIndex) {
let indexPath = path + indexEntry;
let indexPath = dir + indexEntry;
if (staticAssets.getAsset(indexPath) != null) {

@@ -39,0 +44,0 @@ return indexPath;

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