Socket
Socket
Sign inDemoInstall

s3u

Package Overview
Dependencies
0
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.9 to 0.2.10

2

package.json
{
"name": "s3u",
"version": "0.2.9",
"version": "0.2.10",
"description": "S3 URL manipulation helper similar to standard URL class",

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

@@ -12,2 +12,3 @@ # s3u

- Support different S3 providers
- Support both Node.js and browser environment
- Simple and lightweight

@@ -14,0 +15,0 @@ - No dependencies

@@ -18,2 +18,4 @@ export class S3Url {

readonly dirPath: string;
readonly fileName: string;
readonly href: string;

@@ -31,3 +33,5 @@ readonly isValid: string;

setCdn(cdn: boolean): this;
setDirPath(dirPath: string): this;
setDomain(domain: string): this;
setFileName(fileName: string): this;
setKey(key: string): this;

@@ -43,4 +47,7 @@ setProtocol(protocol: string): this;

}): Promise<string>
trimSlashes(options?: { begin?: boolean; end?: boolean }): this;
}
export interface ProviderInterface {

@@ -47,0 +54,0 @@ buildUrl({ s3Url }: { s3Url: S3Url }): string;

@@ -46,2 +46,10 @@ 'use strict';

get dirPath() {
return this.key.split('/').slice(0, -1).join('/');
}
get fileName() {
return this.key.split('/').pop();
}
get href() {

@@ -97,2 +105,7 @@ if (!this.provider) {

setDirPath(dirPath) {
this.setKey(`${dirPath}/${this.fileName}`);
return this;
}
setDomain(domain) {

@@ -103,4 +116,10 @@ this.domain = domain;

setFileName(fileName) {
this.setKey(`${this.dirPath}/${fileName}`);
return this;
}
setKey(key) {
this.key = key;
this.trimSlashes({ begin: true });
return this;

@@ -119,2 +138,18 @@ }

trimSlashes({ begin = false, end = false } = {}) {
let key = this.key;
if (begin) {
key = key.replace(/^\/+/, '');
}
if (end) {
key = key.replace(/\/+$/, '');
}
this.key = key;
return this;
}
toString() {

@@ -121,0 +156,0 @@ return this.href;

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc