2.8.0 • Published 5 months ago

@ampproject/toolbox-cache-url v2.8.0

Weekly downloads
15,474
License
Apache-2.0
Repository
github
Last release
5 months ago

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@beta

Including the Module

ES Module (Browser)

import {ampToolboxCacheUrl} from 'amp-toolbox-cache-url';

CommonJs (Node)

const ampToolboxCacheUrl = require('amp-toolbox-cache-url').createCacheUrl;

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.AmpToolboxCacheUrl;

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);
  });
3.0.0-canary.2

5 months ago

2.8.0

12 months ago

2.8.0-canary.6

1 year ago

2.8.0-canary.5

1 year ago

2.8.0-canary.4

1 year ago

2.8.0-canary.0

1 year ago

2.7.2

1 year ago

2.7.1

1 year ago

2.7.1-alpha.0

1 year ago

2.7.0-alpha.1

2 years ago

2.5.4

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

2.0.0-alpha.0

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.0-beta.1

3 years ago

1.1.0-beta.0

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-beta.9

3 years ago

1.0.0-beta.8

3 years ago

1.0.0-beta.7

3 years ago

1.0.0-beta.6

3 years ago

1.0.0-beta.5

3 years ago

1.0.0-beta.4

3 years ago

1.0.0-beta.3

3 years ago

1.0.0-beta.2

3 years ago

1.0.0-beta.1

3 years ago

1.0.0-beta.0

3 years ago