1.0.4 • Published 7 months ago

iframe-visible v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

iFrame Visible

A simple TypeScript package to check whether a given URL can be embedded in an iframe based on its HTTP headers.

Installation

To install the package, run:

npm install iframe-visible

Usage

You can use the isEmbeddable function to check if a URL is embeddable in an iframe. Here's how to use it:

import { isEmbeddable } from "iframe-visible";

const url = "https://example.com";

isEmbeddable(url)
  .then((embeddable) => {
    if (embeddable) {
      console.log(`${url} can be embedded in an iframe.`);
    } else {
      console.log(`${url} cannot be embedded in an iframe.`);
    }
  })
  .catch((error) => {
    console.error("Error checking embeddability:", error);
  });

using async, await

import { isEmbeddable } from "iframe-visible";

async function checkEmbeddability() {
  const url = "https://example.com";

  try {
    const embeddable = await isEmbeddable(url);
    if (embeddable) {
      console.log(`${url} can be embedded in an iframe.`);
    } else {
      console.log(`${url} cannot be embedded in an iframe.`);
    }
  } catch (error) {
    console.error("Error checking embeddability:", error);
  }
}

checkEmbeddability();

API

isEmbeddable(url: string): Promise<boolean>

  • url: The URL to check.
  • Returns a promise that resolves to true if the URL can be embedded in an iframe, and false otherwise.

Contributing

Feel free to submit issues or pull requests for improvements or bug fixes.

License

This project is licensed under the MIT License.

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago