tall-plugin-meta-refresh
v8.0.0
Published
Tall plugin for following redirects in <meta http-equiv="refresh"> tags
Downloads
822
Maintainers
Readme
tall-plugin-meta-refresh
A plugin for tall
that allows you to follow meta refresh redirects such as:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>The Tudors</title>
<meta
http-equiv="refresh"
content="3;URL='http://thetudors.example.com/'"
/>
</head>
<body>
<p>
This page has moved to
<a href="http://thetudors.example.com/">theTudors.example.com</a>.
Redirecting you automatically in 3 seconds.
</p>
</body>
</html>
Example from W3C.
Installation
With npm:
npm i --save tall-plugin-meta-refresh
or with yarn:
yarn add tall-plugin-meta-refresh
Usage
To enable the plugin on a given tall
instance:
import { locationHeaderPlugin, tall } from 'tall'
import { metaRefreshPlugin } from 'tall-plugin-meta-refresh'
const url = await tall('https://example.com/a-link', {
plugins: [locationHeaderPlugin, metaRefreshPlugin]
})
console.log(url)
Note: the
locationHeaderPlugin
is the standard behavior (following HTTP header location headers) and it should always be used before themetaRefreshPlugin
.
Warning: also be aware that the
metaRefreshPlugin
will consume the entire HTTP response object, so other plugins that might be added after it won't be able to parse the response body.