-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
76 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,15 +12,19 @@ import { Buffer } from "node:buffer"; | |
import fetch from "npm:[email protected]"; | ||
import { XMLParser } from "npm:[email protected]"; | ||
|
||
const parser = new XMLParser(); | ||
|
||
export class Pastebin extends AbstractPastebin { | ||
constructor(config?: IPastebinOptions | string | null) { | ||
super(config); | ||
// This is probably not the best way to do this, but it works | ||
super.parseXML = this.parseXml; | ||
super(config, { | ||
fetch: fetch as unknown as typeof globalThis.fetch, | ||
parseXML: (xml: string): Record<string, string> => { | ||
const data = parser.parse(xml); | ||
return data; | ||
}, | ||
}); | ||
} | ||
|
||
fetch = fetch as unknown as typeof globalThis.fetch; | ||
|
||
async createPasteFromFile( | ||
options: ICreatePasteFileOptions<Buffer> = { file: "" }, | ||
): Promise<unknown> { | ||
|
@@ -50,10 +54,4 @@ export class Pastebin extends AbstractPastebin { | |
|
||
return this.createPaste(pasteOpts); | ||
} | ||
|
||
parseXml = (xml: string): Record<string, string> => { | ||
const parser = new XMLParser(); | ||
const data = parser.parse(xml); | ||
return data; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ScrapeOptions, Scraper as AbstractScraper } from "../lib/Scraper.ts"; | ||
|
||
import fetch from "npm:[email protected]"; | ||
|
||
export class Scraper extends AbstractScraper { | ||
constructor(opts?: ScrapeOptions) { | ||
super(opts, fetch as unknown as typeof globalThis.fetch); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// Copyright 2023 J.W. Lagendijk. All rights reserved. MIT license. | ||
|
||
export * from "./Pastebin.ts"; | ||
export * from "../lib/Scraper.ts"; | ||
export * from "./Scraper.ts"; | ||
export * from "../lib/interfaces.ts"; |