OAuth2 stuff
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-10-18 12:48:16 -05:00
parent a1d04d652e
commit 3efbfecf9d
14 changed files with 397 additions and 94 deletions

View File

@@ -5,6 +5,7 @@ import * as mime from 'mime-types'
import {FileNotFoundError, Filesystem} from './path/Filesystem'
import {Collection} from '../collection/Collection'
import {Readable, Writable} from 'stream'
import {Pipe} from './Pipe'
/**
* An item that could represent a path.
@@ -82,6 +83,8 @@ export class UniversalPath {
protected resourceLocalPath!: string
protected resourceQuery: URLSearchParams = new URLSearchParams()
constructor(
/**
* The path string this path refers to.
@@ -94,6 +97,10 @@ export class UniversalPath {
) {
this.setPrefix()
this.setLocal()
if ( this.isRemote ) {
this.resourceQuery = (new URL(this.toRemote)).searchParams
}
}
/**
@@ -140,6 +147,13 @@ export class UniversalPath {
return new UniversalPath(this.initial)
}
/**
* Get the URLSearchParams for this resource.
*/
get query(): URLSearchParams {
return this.resourceQuery
}
/**
* Get the string of this resource.
*/
@@ -183,7 +197,8 @@ export class UniversalPath {
* Get the fully-prefixed path to this resource.
*/
get toRemote(): string {
return `${this.prefix}${this.resourceLocalPath}`
const query = this.query.toString()
return `${this.prefix}${this.resourceLocalPath}${query ? '?' + query : ''}`
}
/**
@@ -517,4 +532,9 @@ export class UniversalPath {
return false
}
/** Get a new Pipe instance wrapping this. */
toPipe(): Pipe<UniversalPath> {
return Pipe.wrap(this)
}
}