Skip to content

Commit

Permalink
fix(store): do not resolve emails (#500)
Browse files Browse the repository at this point in the history
  • Loading branch information
hjvedvik committed Jul 5, 2019
1 parent 9a10a37 commit 6105069
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions gridsome/lib/store/__tests__/PluginStore.spec.js
Expand Up @@ -524,6 +524,7 @@ test('resolve file paths', () => {
url3: 'git@github.com:gridsome/gridsome.git',
url4: 'ftp://ftp.example.com',
email: 'email@example.com',
email2: 'mailto:email@example.me',
text: 'Lorem ipsum dolor sit amet.',
text2: 'example.com',
text3: 'md',
Expand All @@ -541,6 +542,7 @@ test('resolve file paths', () => {
expect(node.url3).toEqual('git@github.com:gridsome/gridsome.git')
expect(node.url4).toEqual('ftp://ftp.example.com')
expect(node.email).toEqual('email@example.com')
expect(node.email2).toEqual('mailto:email@example.me')
expect(node.text).toEqual('Lorem ipsum dolor sit amet.')
expect(node.text2).toEqual('example.com')
expect(node.text3).toEqual('md')
Expand Down
10 changes: 7 additions & 3 deletions gridsome/lib/store/utils.js
Expand Up @@ -4,6 +4,7 @@ const isUrl = require('is-url')
const mime = require('mime-types')
const camelCase = require('camelcase')
const isRelative = require('is-relative')
const { isResolvablePath } = require('../utils')

const nonValidCharsRE = new RegExp('[^a-zA-Z0-9_]', 'g')
const leadingNumberRE = new RegExp('^([0-9])')
Expand Down Expand Up @@ -34,10 +35,13 @@ exports.resolvePath = function (origin, toPath, options = {}) {

if (typeof toPath !== 'string') return toPath
if (typeof origin !== 'string') return toPath
if (path.extname(toPath).length <= 1) return toPath
if (isUrl(toPath)) return toPath
if (mime.lookup(toPath) === 'application/x-msdownload') return toPath
if (!mime.lookup(toPath)) return toPath
if (!isResolvablePath(toPath)) return toPath

const mimeType = mime.lookup(toPath)

if (!mimeType) return toPath
if (mimeType === 'application/x-msdownload') return toPath

const url = isUrl(origin) ? exports.parseUrl(origin) : null
const contextPath = url && resolveAbsolute === true ? url.baseUrl : context
Expand Down

0 comments on commit 6105069

Please sign in to comment.