Socket
Socket
Sign inDemoInstall

@ampproject/toolbox-cache-url

Package Overview
Dependencies
4
Maintainers
16
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ampproject/toolbox-cache-url

Transform canonical URLs into AMP Cache URLs


Version published
Weekly downloads
563
increased by8.69%
Maintainers
16
Install size
195 kB
Created
Weekly downloads
 

Changelog

Source

2.9.0 (2022-06-23)

:rocket: Enhancement
  • cloudflare-optimizer-scripts
    • #1318 Add support for Opaque redirects (@abdulhannanali)
  • optimizer
:bug: Bug Fix
  • optimizer
    • #1319 Fix i-amphtml-sizer responsive issue (@ediamin)
    • #1312 More robust auto extension import (@sebastianbenz)
    • #1303 Fix for issue #1302: "SSR: Duplicated ids in rendered markup, if there are nodes with attributes 'media', 'heights' or 'sizes'" (@DK-Stern)
    • #1305 Fix for issue #1304: "SSR: Transforming of nodes with attribute 'heights' fails, if value contains multiple media queries" (@DK-Stern)
:house: Internal
  • cache-url, cli, cloudflare-optimizer-scripts, linter, optimizer-docker, optimizer, page-experience, update-cache
  • cache-list, cache-url, cli, cloudflare-optimizer-scripts, core, cors, linter, optimizer-docker, optimizer-express, optimizer, page-experience, runtime-fetch, runtime-version, script-csp, update-cache, validator-rules
Committers: 6

Readme

Source

AMP-Toolbox Cache URL

npm version

Translates an URL from the origin to the AMP Cache URL format, according to the specification available in the AMP documentation. This includes the SHA256 fallback URLs used by the AMP Cache on invalid human-readable cache urls.

Usage

Install via:

$ npm install @ampproject/toolbox-cache-url

Including the Module

ES Module (Browser)
import {ampToolboxCacheUrl} from '@ampproject/toolbox-cache-url';
CommonJs (Node)
const ampToolboxCacheUrl = require('@ampproject/toolbox-cache-url');
UMD (Node, Browser)

In the browser, include the UMD module in an HTML <script> tag. If using node, replace window with global.

const {ampToolboxCacheUrl} = window.ToolboxCacheUrl;

Using the module

  // Get an AMP Cache URL from a cache domain, and a canonical URL
  ampToolboxCacheUrl.createCacheUrl('cdn.ampproject.org', 'https://www.example.com').then((cacheUrl) => {
    // This would log: 
    // 'https://www-example-com.cdn.ampproject.org/c/s/www.example.com/'
    console.log(cacheUrl);
  });

  // Transform a canonical URL to an AMP Cache subdomain
  ampToolboxCacheUrl.createCurlsSubdomain('https://www.example.com').then((curlsSubdomain) => {
    // This would log: 
    // 'www-example-com'
    console.log(curlsSubdomain);
  });

Keywords

FAQs

Last updated on 23 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc