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

hapiest-cloudfront-url

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hapiest-cloudfront-url - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

6

lib/cloudfrontUrlService.js

@@ -16,3 +16,3 @@ 'use strict';

/**
* @param {String} cloudfrontDomainName
* @param {String} cloudfrontDomainName - note, cloudfrontDomainName can also include a path portion to support "local" CF distributions stored in a particular folder on localhost
* @param {Boolean} enabled

@@ -73,4 +73,4 @@ * @param {CloudfrontOrigin[]} origins

isDistributionUrl(url) {
const urlInfo = Url.parse(url);
return urlInfo.host === this._cloudfrontDomainName;
const urlNoProtocol = url.replace(/^(http:\/\/|https:\/\/|\/\/)/,'');
return urlNoProtocol.startsWith(this._cloudfrontDomainName);
}

@@ -77,0 +77,0 @@

{
"name": "hapiest-cloudfront-url",
"version": "0.0.3",
"version": "0.0.4",
"description": "Maps origin URLs to an AWS Cloudfront distribution URL",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -98,2 +98,18 @@ 'use strict';

it('Should return true when the url matches distribution and false when it does not even for distributions with paths in the domain name', function() {
const cfUrlService = CloudfrontUrlServiceFactory.create({
cloudfrontDomainName: 'localhost:3000/localstorage/public/images',
enabled: true,
origins: [{host: 'localhost', port: 3000, path: 'localstorage/bucket/public'}]
});
const urlToCheck_true = 'http://localhost:3000/localstorage/public/images/folder/thumbnail.jpg';
const isDistributionUrl_true = cfUrlService.isDistributionUrl(urlToCheck_true);
isDistributionUrl_true.should.be.True();
const urlToCheck_false = 'http://localhost:3000/localstorage/thumbnail.jpg';
const isDistributionUrl_false = cfUrlService.isDistributionUrl(urlToCheck_false);
isDistributionUrl_false.should.be.False();
});
});

@@ -100,0 +116,0 @@

Sorry, the diff of this file is not supported yet

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