Skip to content

Commit d058742

Browse files
committed
0;276;0cMerge branch 'main' of github.com:holepunchto/pear-api into setup-test
2 parents 9686758 + 53be3ad commit d058742

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pear-api",
3-
"version": "1.6.11",
3+
"version": "1.6.14",
44
"description": "Pear API Base & Integration Module",
55
"main": "index.js",
66
"scripts": {

state.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const fs = isBare ? require('bare-fs') : require('fs')
55
const path = isBare ? require('bare-path') : require('path')
66
const { pathToFileURL } = require('url-file-url')
77
const hypercoreid = require('hypercore-id-encoding')
8+
const pearLink = require('pear-link')
89
const z32 = require('z32')
910
const crypto = require('hypercore-crypto')
1011
const { PLATFORM_DIR, SWAP, RUNTIME } = require('pear-api/constants')
@@ -40,7 +41,7 @@ module.exports = class State {
4041
static injestPackage (state, pkg, overrides = {}) {
4142
state.manifest = pkg
4243
state.main = pkg?.main || 'index.html'
43-
state.options = pkg?.pear || null
44+
state.options = pkg?.pear || {}
4445
state.name = pkg?.pear?.name || pkg?.name || null
4546
state.links = pkg?.pear?.links || null
4647
state.gui = pkg?.pear?.gui || null
@@ -148,7 +149,7 @@ module.exports = class State {
148149
this.stage = stage
149150
this.fragment = fragment
150151
this.linkData = segment
151-
this.link = link ? (link.startsWith(protocol) ? link : pathToFileURL(link).toString()) : null
152+
this.link = link ? (link.startsWith(protocol) ? link : pearLink.normalize(pathToFileURL(link).toString())) : null
152153
this.key = key
153154
this.applink = key ? this.link.slice(0, -(~~(pathname?.length) + ~~(hash?.length))) : null
154155
this.alias = alias
@@ -165,7 +166,8 @@ module.exports = class State {
165166
this.env.NODE_ENV = this.env.NODE_ENV || 'production'
166167
}
167168
this.constructor.injestPackage(this, pkg, { links })
168-
const invalidStorage = this.key === null && this.storage !== null && this.storage.startsWith(this.dir) && this.storage.includes('/pear/pear/') === false
169+
const invalidStorage = this.key === null && this.storage !== null
170+
&& this.storage.startsWith(this.dir) && this.storage.includes(path.sep + 'pear' + path.sep + 'pear' + path.sep) === false
169171
if (invalidStorage) throw ERR_INVALID_APP_STORAGE('Application Storage may not be inside the project directory. --store "' + this.storage + '" is invalid')
170172
const invalidName = /^[@/a-z0-9-_]+$/.test(this.name) === false
171173
if (invalidName) throw ERR_INVALID_APP_NAME('The package.json name / pear.name field must be lowercase and one word, and may contain letters, numbers, hyphens (-), underscores (_), forward slashes (/) and asperands (@).')

0 commit comments

Comments
 (0)