Skip to content

fix(encode_url): skip encode non-urls#102

Merged
curbengh merged 3 commits intohexojs:masterfrom
curbengh:mailto
Sep 23, 2019
Merged

fix(encode_url): skip encode non-urls#102
curbengh merged 3 commits intohexojs:masterfrom
curbengh:mailto

Conversation

@curbengh
Copy link
Contributor

@curbengh curbengh commented Sep 22, 2019

url.parse(str).slashes is used to avoid treating mailto: as a transfer protocol (e.g. http, ftp).

const { parse } = require('url')
console.log(parse('mailto:abc@example.com'))
/*
Url {
  protocol: 'mailto:',
  slashes: null,
  auth: 'abc',
  host: 'example.com',
  port: null,
  hostname: 'example.com',
  hash: null,
  search: null,
  query: null,
  pathname: null,
  path: null,
  href: 'mail:abc@example.com'
}
*/

This avoids null from being appended undesirably.


  • Expected behavior
encodeURL('mailto:abc@example.com')
// mailto:abc@example.com
  • Actual behavior
encodeURL('mailto:abc@example.com')
// mailto:abc@example.comnull

Address hexojs/hexo#3710 (comment)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 95.122% when pulling d56cd07 on curbengh:mailto into 486f4a0 on hexojs:master.

@coveralls
Copy link

coveralls commented Sep 22, 2019

Coverage Status

Coverage increased (+0.02%) to 95.122% when pulling 9e3af48 on curbengh:mailto into 486f4a0 on hexojs:master.

@curbengh curbengh merged commit ceb307c into hexojs:master Sep 23, 2019
@curbengh curbengh deleted the mailto branch September 23, 2019 02:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants