Skip to content

Commit

Permalink
Fix fetch resources url incorrect
Browse files Browse the repository at this point in the history
  • Loading branch information
web-flow committed Nov 1, 2020
1 parent fce0ea7 commit 10bdf64
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.1.2] - 2020-11-01

### Fixed
- Fix fetch resources url incorrect

## [2.1.1] - 2020-10-30

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wabarc/cairn",
"version": "2.1.1",
"version": "2.1.2",
"description": "Node package and CLI tool for saving web page as single HTML file",
"main": "dist/cairn.js",
"types": "dist/cairn.d.ts",
Expand Down
8 changes: 6 additions & 2 deletions src/uri.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createAbsoluteURL, http } from './utils';
import { createAbsoluteURL, isValidURL, http } from './utils';
import { css } from './css';

class URI {
Expand All @@ -9,6 +9,10 @@ class URI {
}

const assetURL = createAbsoluteURL(url, baseURL);
if (!isValidURL(assetURL)) {
return content;
}

const response = await http.fetch(assetURL);
if (typeof response !== 'object' || !Object.prototype.hasOwnProperty.call(response, 'data')) {
return content;
Expand All @@ -17,7 +21,7 @@ class URI {

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

return content;
Expand Down

0 comments on commit 10bdf64

Please sign in to comment.