Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gatsby-core-utils): add url resolve (#15510)
* rename gatsby-utils folder * feat(gatsby-core-utils): add url resolve * fix repo field
- Loading branch information
Showing
18 changed files
with
37 additions
and
5 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const { resolve } = require(`../url`) | ||
|
||
describe(`url`, () => { | ||
describe(`resolve`, () => { | ||
it(`resolves segments into valid url pathname`, () => { | ||
const paths = [`/`, ``, `./foo`, `bar`, `baz`] | ||
const actual = resolve(...paths) | ||
expect(actual).toBe(`/foo/bar/baz`) | ||
}) | ||
}) | ||
}) |
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
packages/gatsby-utils/src/index.js → packages/gatsby-core-utils/src/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
exports.createContentDigest = require(`./create-content-digest`) | ||
exports.joinPath = require(`./path`).joinPath | ||
exports.cpuCoreCount = require(`./cpu-core-count`) | ||
exports.urlResolve = require(`./url`).resolve |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const path = require(`path`) | ||
const os = require(`os`) | ||
|
||
/** | ||
* @type {import('../index').urlResolve} | ||
*/ | ||
export function resolve(...segments) { | ||
const joinedPath = path.join(...segments) | ||
if (os.platform() === `win32`) { | ||
return joinedPath.replace(/\\/g, `/`) | ||
} | ||
|
||
return joinedPath | ||
} |