From b94845e008931bfaee56b91db1f892af7a6d339f Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 3 Aug 2017 03:19:59 +0400 Subject: Fix HTTP crawler outputting {..., items: {items: [...]}} --- src/crawl-http.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crawl-http.js b/src/crawl-http.js index e776b9c..7308f3f 100755 --- a/src/crawl-http.js +++ b/src/crawl-http.js @@ -77,7 +77,7 @@ function crawl(absURL, opts = {}, internals = {}) { verboseLog("[Dir] " + linkURL) return crawl(linkURL, opts, Object.assign({}, internals)) - .then(items => ({name, items})) + .then(({ items }) => ({name, items})) } else { // It's a file! -- cgit 1.3.0-6-gf8a5 From 3b6b9425b84f624b4cca9c3e8123e7f5554aed51 Mon Sep 17 00:00:00 2001 From: Florrie Date: Thu, 3 Aug 2017 03:34:57 +0400 Subject: Kill '/' when at the end of a link name in crawl-http --- src/crawl-http.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/crawl-http.js b/src/crawl-http.js index 76f3941..ad3b776 100755 --- a/src/crawl-http.js +++ b/src/crawl-http.js @@ -47,7 +47,15 @@ function crawl(absURL, opts = {}, internals = {}) { const links = getHTMLLinks(text) return Promise.all(links.map(link => { - const [ name, href ] = link + let [ name, href ] = link + + // If the name (that's the content inside of ..) ends with a + // slash, that's probably just an artifact of a directory lister; + // not actually part of the intended content. So we remove it! + if (name.endsWith('/')) { + name = name.slice(0, -1) + } + const urlObj = new url.URL(href, absURL) const linkURL = url.format(urlObj) -- cgit 1.3.0-6-gf8a5