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

relateurl

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

relateurl

Minify URLs by converting them from absolute to relative.

  • 0.2.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
12M
increased by3.52%
Maintainers
1
Weekly downloads
 
Created

What is relateurl?

The relateurl npm package is designed to simplify the process of converting absolute URLs to relative URLs, based on the current page's URL. It can be particularly useful in web development scenarios where you need to optimize link references within your site or application.

What are relateurl's main functionalities?

Convert absolute URL to relative URL

This feature allows you to convert an absolute URL to a relative URL based on a base URL. It's useful for reducing the length of URLs in your HTML or CSS files.

"const RelateUrl = require('relateurl');\nconst absoluteUrl = 'http://example.com/dir/file';\nconst options = { output: RelateUrl.SHORTEST };\nconst relativeUrl = RelateUrl.relate('http://example.com/', absoluteUrl, options);\nconsole.log(relativeUrl); // Outputs: 'dir/file'"

Customize output with options

This feature demonstrates how you can customize the output of the relative URL using various options, such as making it scheme-relative or choosing the type of relative path.

"const RelateUrl = require('relateurl');\nconst absoluteUrl = 'https://example.com/dir/file';\nconst options = {\n  output: RelateUrl.PATH_RELATIVE,\n  schemeRelative: true\n};\nconst relativeUrl = RelateUrl.relate('https://example.com/another-dir/', absoluteUrl, options);\nconsole.log(relativeUrl); // Outputs: '../../dir/file'"

Other packages similar to relateurl

Keywords

FAQs

Package last updated on 14 Jul 2016

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