Skip to content

Commit

Permalink
Adding a check to verify path strings in front matter are prepended w…
Browse files Browse the repository at this point in the history
…ith a forward slash
  • Loading branch information
Michael Deeb committed Mar 29, 2016
1 parent 857f9df commit 6dc8bf4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/utils/glob-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import fs from 'fs'
import frontMatter from 'front-matter'
import htmlFrontMatter from 'html-frontmatter'
import objectAssign from 'object-assign'
import invariant from 'invariant'
const debug = require('debug')('gatsby:glob')
let rewritePath
try {
Expand Down Expand Up @@ -76,6 +77,11 @@ module.exports = (directory, callback) => {
if (!(parsed.name.slice(0, 1) === '_')) {
if (data.path) {
// Path was hardcoded.
const pathInvariantMessage = `
You're setting path to ${data.path} for ${parsed.dirname},
but it should be /${data.path}
`
invariant((data.path.charAt(0) === '/'), pathInvariantMessage)
pageData.path = data.path
} else if (rewritePath) {
pageData.path = rewritePath(parsed, pageData)
Expand Down

0 comments on commit 6dc8bf4

Please sign in to comment.