Skip to content

Commit 10bdf64

Browse files
committed
Fix fetch resources url incorrect
1 parent fce0ea7 commit 10bdf64

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [2.1.2] - 2020-11-01
10+
11+
### Fixed
12+
- Fix fetch resources url incorrect
13+
914
## [2.1.1] - 2020-10-30
1015

1116
### Fixed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@wabarc/cairn",
3-
"version": "2.1.1",
3+
"version": "2.1.2",
44
"description": "Node package and CLI tool for saving web page as single HTML file",
55
"main": "dist/cairn.js",
66
"types": "dist/cairn.d.ts",

src/uri.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createAbsoluteURL, http } from './utils';
1+
import { createAbsoluteURL, isValidURL, http } from './utils';
22
import { css } from './css';
33

44
class URI {
@@ -9,6 +9,10 @@ class URI {
99
}
1010

1111
const assetURL = createAbsoluteURL(url, baseURL);
12+
if (!isValidURL(assetURL)) {
13+
return content;
14+
}
15+
1216
const response = await http.fetch(assetURL);
1317
if (typeof response !== 'object' || !Object.prototype.hasOwnProperty.call(response, 'data')) {
1418
return content;
@@ -17,7 +21,7 @@ class URI {
1721

1822
const contentType = response.headers['content-type'] || '';
1923
if (contentType === 'text/css') {
20-
content = await css.process(Buffer.from(content).toString(), baseURL);
24+
content = await css.process(Buffer.from(content).toString(), assetURL);
2125
}
2226

2327
return content;

0 commit comments

Comments
 (0)