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

@ampproject/toolbox-cache-url

Package Overview
Dependencies
Maintainers
16
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ampproject/toolbox-cache-url

Transform canonical URLs into AMP Cache URLs

  • 2.10.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
579
decreased by-23.82%
Maintainers
16
Weekly downloads
 
Created
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

Package last updated on 14 Jun 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc