Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
Fix malformed url parsing (#55)
Browse files Browse the repository at this point in the history
* Fix malformed url parsing

Check and fix urls that are parsed with three forward slahes instead of two (e.g. https:///example.com turns into https://example.com)
Example of this use case can be seen at https://manhuaus.com/manga/its-over-empress-husband-is-actually-invincible/chapter-28/ (the first image has it's data-src attribute be https:///cdn.manhuaus.com/madara/2023-04-14/8884899366438cbffa57714.48601788.jpg in the html file)

* Update base version
  • Loading branch information
Ivanmatthew committed Apr 16, 2023
1 parent 2502e6a commit bb62285
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Madara.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
sourceSettings
} from './MadaraSettings'

const BASE_VERSION = '2.2.5'
const BASE_VERSION = '2.2.6'
export const getExportVersion = (EXTENSION_VERSION: string): string => {
return BASE_VERSION.split('.').map((x, index) => Number(x) + Number(EXTENSION_VERSION.split('.')[index])).join('.')
}
Expand Down
6 changes: 5 additions & 1 deletion src/MadaraParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ export class Parser {
if (!page) {
throw new Error(`Could not parse page for ${mangaId}/${chapterId}`)
}

pages.push(encodeURI(await page))
}

Expand Down Expand Up @@ -264,6 +263,11 @@ export class Parser {
.replace('-350x476', '')
}
}

// Malforumed url fix (Turns https:///example.com into https://example.com (or the http:// equivalent))
image = image?.replace(/https:\/\/\//g, 'https://') // only changes urls with https protocol
image = image?.replace(/http:\/\/\//g, 'http://') // only changes urls with http protocol

return decodeURI(this.decodeHTMLEntity(image?.trim() ?? ''))
}

Expand Down

0 comments on commit bb62285

Please sign in to comment.