Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Sep 23, 2019
Merged

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