mirror of
https://github.com/fluencelabs/dweb-transports
synced 2025-03-15 18:30:49 +00:00
Correctly recognize /arc/archive.org
This commit is contained in:
parent
5930809ad1
commit
289362fcdd
@ -56,7 +56,6 @@ class TransportIPFS extends Transport {
|
||||
|
||||
Fields:
|
||||
ipfs: object returned when starting IPFS
|
||||
TODO - this is not complete
|
||||
*/
|
||||
|
||||
constructor(options) {
|
||||
@ -313,7 +312,7 @@ class TransportIPFS extends Transport {
|
||||
if (res.remainderPath.length)
|
||||
{ // noinspection ExceptionCaughtLocallyJS
|
||||
throw new errors.TransportError("Not yet supporting paths in p_rawfetch");
|
||||
} //TODO-PATH
|
||||
}
|
||||
let buff;
|
||||
if (res.value.constructor.name === "DAGNode") { // Kludge to replace above, as its not matching the type against the "require" above.
|
||||
// We retrieved a DAGNode, call files.cat (the node will come from the cache quickly)
|
||||
|
@ -259,7 +259,7 @@ class TransportWEBTORRENT extends Transport {
|
||||
}
|
||||
|
||||
async p_addTorrentFromTorrentFile(torrentFilePath, filesPath) {
|
||||
// TODO: doc
|
||||
// TODO-API: doc
|
||||
try {
|
||||
const opts = { path: filesPath };
|
||||
const oldTorrent = this.webtorrent.get(torrentFilePath);
|
||||
|
@ -28,7 +28,6 @@ class TransportWOLK extends Transport {
|
||||
this.options = options; // Dictionary of options
|
||||
this.wolk = undefined;
|
||||
this.name = "WOLK"; // For console log etc
|
||||
//TODO: Change name to WOLK once we understand everything
|
||||
this.supportURLs = ['wolk'];
|
||||
this.supportFunctions = [ 'fetch', 'connection', 'get', 'set', ]; // 'store' - requires chunkdata; 'createReadStream' not implemented
|
||||
this.status = Transport.STATUS_LOADED;
|
||||
|
@ -1,7 +1,6 @@
|
||||
const Url = require('url');
|
||||
const errors = require('./Errors');
|
||||
const utils = require('./utils');
|
||||
//process.env.DEBUG = "dweb-transports"; //TODO-DEBUG set at top level
|
||||
const debug = require('debug')('dweb-transports');
|
||||
const httptools = require('./httptools');
|
||||
const each = require('async/each');
|
||||
@ -202,7 +201,6 @@ class Transports {
|
||||
debug("Fetching %s via %s", url.href, t.name);
|
||||
let data = await t.p_rawfetch(url, opts); // throws errors if fails or timesout
|
||||
debug("Fetching %s via %s succeeded %d bytes", url.href, t.name, data.length);
|
||||
//TODO-MULTI-GATEWAY working here - it doesnt quite work yet as the "Add" on browser gets different url than on server
|
||||
if (opts.relay && failedtransports.length) {
|
||||
debug("Fetching attempting relay of %d bytes from %s to %o", data.length, url.href, failedtransports.map(t=>t.name));
|
||||
this._p_rawstore(failedtransports, data)
|
||||
@ -293,8 +291,6 @@ class Transports {
|
||||
returns: undefined
|
||||
throws: TransportError with message being concatenated messages of transports if NONE of them succeed.
|
||||
*/
|
||||
//TODO-REFACTOR remove dependecy on the object having a .preflight, this should be handled one layer up.
|
||||
//TODO-REFACTOR requires changes in: dweb-transports: TransportXyz, Transport, API.md; dweb-objects: CommonList.js, test.js; dweb-serviceworker/TransportsProxy.js;
|
||||
//TODO-MULTI-GATEWAY might be smarter about not waiting but Promise.race is inappropriate as returns after a failure as well.
|
||||
urls = await this.p_resolveNames(urls); // If naming is loaded then convert to a name
|
||||
let tt = this.validFor(urls, "add"); // Valid connected transports that support "store"
|
||||
@ -788,6 +784,7 @@ class Transports {
|
||||
]
|
||||
const arcpatts = [ // No overlap between patts & arcpatts, so order unimportant
|
||||
/^http[s]?:[/]+[^/]+[/](archive).(org)[/]*(.*)/i, // https://localhost;123/(archive.org)/(internal)
|
||||
/^http[s]?:[/]+[^/]+[/]arc[/](archive).(org)[/]*(.*)/i, // https://localhost;123/arc/(archive.org)/(internal)
|
||||
/^http[s]?:[/]+dweb.(\w+)[.]([^/]+)[/]*(.*)/i, // https://dweb.(proto).(dom.ain)/(internal) # Before dweb.dom.ain
|
||||
// /^http[s]?:[/]+dweb.([^/]+[.][^/]+[/]*.*)/i, // https://dweb.(dom.ain)/internal) or https://dweb.(domain) Handled by coe on recognizing above
|
||||
/^(http[s])?:[/]+([^/]+)[/]+(.*)/i, // https://dom.ain/pa/th
|
||||
|
@ -62,7 +62,6 @@ httptools.p_httpfetch = async function(httpurl, init, {wantstream=false, retries
|
||||
init: {headers}
|
||||
resolves to: data as text or json depending on Content-Type header
|
||||
throws: TransportError if fails to fetch
|
||||
//TODO explicitly parameterise if want it to loop
|
||||
*/
|
||||
try {
|
||||
// THis was get("range") but that works when init.headers is a Headers, but not when its an object
|
||||
|
Loading…
x
Reference in New Issue
Block a user