Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
seantomburke committed Nov 6, 2021
1 parent 2b38b2b commit 3fa9d93
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/assets/sitemapper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 17 additions & 17 deletions sitemapper.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export interface SitemapperResponse {
url: string;
sites: string[];
errors: SitemapperErrorData[];
url: string;
sites: string[];
errors: SitemapperErrorData[];
}

export interface SitemapperErrorData {
Expand All @@ -11,26 +11,26 @@ export interface SitemapperErrorData {
}

export interface SitemapperOptions {
url?: string;
timeout?: number;
requestHeaders?: {[name: string]: string};
debug?: boolean;
concurrency?: number;
retries?: number;
url?: string;
timeout?: number;
requestHeaders?: {[name: string]: string};
debug?: boolean;
concurrency?: number;
retries?: number;
}

declare class Sitemapper {

timeout: number;
timeout: number;

constructor(options: SitemapperOptions)
constructor(options: SitemapperOptions)

/**
* Gets the sites from a sitemap.xml with a given URL
*
* @param url URL to the sitemap.xml file
*/
fetch(url?: string): Promise<SitemapperResponse>;
/**
* Gets the sites from a sitemap.xml with a given URL
*
* @param url URL to the sitemap.xml file
*/
fetch(url?: string): Promise<SitemapperResponse>;
}

export default Sitemapper;
4 changes: 2 additions & 2 deletions src/assets/sitemapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default class Sitemapper {

// Otherwise notify of another error
return {
error: error.error,
error: `Error occurred: ${error.name}`,
data: error
};
}
Expand Down Expand Up @@ -279,7 +279,7 @@ export default class Sitemapper {
.filter(result => (result.errors.length == 0))
.reduce((prev, curr) => prev.concat(curr.sites), []);
const errors = results
.filter(result => result.errors)
.filter(result => result.errors.length)
.reduce((prev, curr) => prev.concat(curr.errors), []);

return {
Expand Down
1 change: 1 addition & 0 deletions src/tests/test.es5.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('Sitemapper', function () {
sitemapper.fetch(url)
.then(data => {
data.sites.should.be.Array;
data.errors.should.be.Array;
done();
})
.catch(error => {
Expand Down
6 changes: 6 additions & 0 deletions src/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,12 @@ describe('Sitemapper', function () {
it('gibberish.gibberish should fail silently with an empty array', function (done) {
this.timeout(30000);
const url = 'http://gibberish.gibberish';
sitemapper.debug = true;
sitemapper.fetch(url)
.then(data => {
data.sites.should.be.Array;
data.errors.should.be.Array;
console.log(data);
done();
})
.catch(error => {
Expand Down Expand Up @@ -130,6 +133,8 @@ describe('Sitemapper', function () {
sitemapper.fetch(url)
.then(data => {
data.sites.should.be.Array;
data.errors.should.be.Array;
console.log(data);
done();
})
.catch(error => {
Expand Down Expand Up @@ -187,6 +192,7 @@ describe('Sitemapper', function () {
sitemapper.fetch(url)
.then(data => {
data.sites.should.be.Array;
data.errors.should.be.Array;
data.sites.length.should.be.greaterThan(0);
done();
})
Expand Down

0 comments on commit 3fa9d93

Please sign in to comment.