hexojs / hexo

A fast, simple & powerful blog framework, powered by Node.js.
https://hexo.io
MIT License
39.23k stars 4.83k forks source link

TypeError [ERR_INVALID_URL]: Invalid URL #4502

Closed AriaLyy closed 4 years ago

AriaLyy commented 4 years ago

Check List

Please check followings before submitting a new issue.

Expected behavior

No error is reported when executing the command

Actual behavior

bug message

INFO  Validating config
WARN  Deprecated config detected: "external_link" with a Boolean value is deprecated. See https://hexo.io/docs/configuration for more details.
INFO  Start processing
FATAL {
  err: TypeError [ERR_INVALID_URL]: Invalid URL: http://localhost:5555即可查看。
      at onParseError (internal/url.js:256:9)
      at new URL (internal/url.js:332:5)
      at encodeURL (/Users/aria/dev/blog/node_modules/hexo-util/lib/encode_url.js:8:20)
      at Renderer.link (/Users/aria/dev/blog/node_modules/hexo-renderer-marked/lib/renderer.js:56:27)
      at Parser.parseInline (/Users/aria/dev/blog/node_modules/marked/src/Parser.js:211:27)
      at Parser.parse (/Users/aria/dev/blog/node_modules/marked/src/Parser.js:162:47)
      at Function.parse (/Users/aria/dev/blog/node_modules/marked/src/Parser.js:27:19)
      at marked (/Users/aria/dev/blog/node_modules/marked/src/marked.js:110:19)
      at Hexo.module.exports (/Users/aria/dev/blog/node_modules/hexo-renderer-marked/lib/renderer.js:138:10)
      at Hexo.tryCatcher (/Users/aria/dev/blog/node_modules/bluebird/js/release/util.js:16:23)
      at Hexo.<anonymous> (/Users/aria/dev/blog/node_modules/bluebird/js/release/method.js:15:34)
      at /Users/aria/dev/blog/node_modules/hexo/lib/hexo/render.js:75:22
      at tryCatcher (/Users/aria/dev/blog/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/Users/aria/dev/blog/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/Users/aria/dev/blog/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromiseCtx (/Users/aria/dev/blog/node_modules/bluebird/js/release/promise.js:641:10)
      at _drainQueueStep (/Users/aria/dev/blog/node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (/Users/aria/dev/blog/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/Users/aria/dev/blog/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/Users/aria/dev/blog/node_modules/bluebird/js/release/async.js:15:14)
      at processImmediate (internal/timers.js:458:21) {
    input: 'http://localhost:5555即可查看。',
    code: 'ERR_INVALID_URL'
  }
} Something's wrong. Maybe you can find the solution here: %s https://hexo.io/docs/troubleshooting.html

How to reproduce?

Is the problem still there under "Safe mode"?

yes

Environment & Settings

node version: v14.5.0
npm version: 6.14.8

Your site _config.yml (Optional)

# Hexo Configuration
## Docs: https://hexo.io/docs/configuration.html
## Source: https://github.com/hexojs/hexo/

# Site
title: 水沝淼
subtitle: 不忘初心方得始终,始终易得初心难觅。
description: 
author: AriaLyy
# language: zh-Hans
language: zh-CN
timezone:

# hexo sitemap网站地图
sitemap:
  path: sitemap.xml
baidusitemap:
  path: baidusitemap.xml

# 多说评论
# duoshuo_shortname: AriaLyy

# 头像
avatar: /images/avatar_icon.png
# URL
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
url: https://www.laoyuyu.me
root: /
permalink: :year/:month/:day/:title/
permalink_defaults:

# Directory
source_dir: source
public_dir: public
tag_dir: tags
archive_dir: archives
category_dir: categories
code_dir: downloads/code
i18n_dir: :lang
skip_render:

# Writing
new_post_name: :title.md # File name of new posts
default_layout: post
titlecase: false # Transform title into titlecase
external_link: true # Open external links in new tab
filename_case: 0
render_drafts: false
post_asset_folder: false
relative_link: false
future: true
highlight:
  enable: true
  line_number: false
  auto_detect: false
  tab_replace:

# Category & Tag
default_category: uncategorized
category_map:
tag_map:

# Date / Time format
## Hexo uses Moment.js to parse and display date
## You can customize the date format as defined in
## http://momentjs.com/docs/#/displaying/format/
date_format: YYYY-MM-DD
time_format: HH:mm:ss

# Pagination
## Set per_page to 0 to disable pagination
per_page: 8
pagination_dir: page

# Extensions
## Plugins: https://hexo.io/plugins/
## Themes: https://hexo.io/themes/
#theme: landscape
# theme: next
# theme: yilia
#theme: maupassant
theme: BlueLake
# event 需要npm install --save hexo-renderer-sass
# theme: even

# search server,you need use the cmd install: npm install hexo-generator-searchdb --save
search:
  path: search.xml
  field: post
  format: html
  limit: 10000

# Deployment
## Docs: https://hexo.io/docs/deployment.html
# git@github.com:AriaLyy/AriaLyy.github.io.git
#116.196.91.167
deploy:
  type: git
  repository: git@laoyuyu.me:/var/repo/blog.git
  branch: master

#RSS订阅
plugin:
- hexo-generator-feed

#Feed Atom
feed:
type: atom
path: atom.xml
limit: 20

jsonContent:
  meta: false
  pages: false
  posts:
    title: true #文章标题
    date: true #发表日期
    path: true #路径
    text: true #文本字段
    raw: false
    content: false
    slug: false
    updated: false
    comments: false
    link: false
    permalink: false
    excerpt: false
    categories: false
    tags: true

Your theme _config.yml (Optional)

Hexo and Plugin version(npm ls --depth 0)

hexo-site@0.0.0 /Users/aria/dev/blog
├── hexo@5.1.1
├── hexo-generator-archive@1.0.0
├── hexo-generator-category@1.0.0
├── hexo-generator-index@2.0.0
├── hexo-generator-tag@1.0.0
├── hexo-renderer-ejs@1.0.0
├── hexo-renderer-marked@3.1.0
├── hexo-renderer-stylus@2.0.0
├── hexo-server@2.0.0
└── hexo-util@2.4.0

Your package.json package.json

{
  "name": "hexo-site",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "build": "hexo generate",
    "clean": "hexo clean",
    "deploy": "hexo deploy",
    "server": "hexo server"
  },
  "hexo": {
    "version": "5.1.1"
  },
  "dependencies": {
    "hexo": "^5.0.0",
    "hexo-generator-archive": "^1.0.0",
    "hexo-generator-category": "^1.0.0",
    "hexo-generator-index": "^2.0.0",
    "hexo-generator-tag": "^1.0.0",
    "hexo-renderer-ejs": "^1.0.0",
    "hexo-renderer-marked": "^3.0.0",
    "hexo-renderer-stylus": "^2.0.0",
    "hexo-server": "^2.0.0",
    "hexo-util": "^2.4.0"
  }
}

Others

curbengh commented 4 years ago

http://localhost:5555即可查看

need a space after the link, http://localhost:5555 即可查看

SukkaW commented 4 years ago

@curbengh Should we make encodeURL more foolproof?

curbengh commented 4 years ago

As in ignoring invalid links? Validating link is more of a side-effect of encodeURL, but I find it quite useful.

SukkaW commented 4 years ago

As in ignoring invalid links? Validating link is more of a side-effect of encodeURL, but I find it quite useful.

Then add foolproof in hexo-renderer-marked instead.

curbengh commented 4 years ago

Remove encodeURL from the plugin? https://github.com/hexojs/hexo-renderer-marked/blob/29b49aad3c55ec3d7563d006318bede45cbb54f9/lib/renderer.js#L56

Alternatively, we could mention this error in https://hexo.io/docs/troubleshooting.

SukkaW commented 4 years ago

Remove encodeURL from the plugin? https://github.com/hexojs/hexo-renderer-marked/blob/29b49aad3c55ec3d7563d006318bede45cbb54f9/lib/renderer.js#L56

Simply add a try... catch... will be fine.