Skip to content

Commit a7c95ad

Browse files
committed
Fix server overriding gist urls
1 parent 0afd22c commit a7c95ad

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/runtime/server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ function IDEMessageHandler(client:SocketRuntimeClient, message) {
185185

186186
let content:string;
187187
let path:string;
188+
let isLocal = hash.indexOf("gist:") === 0;
188189

189190
// If we're in file mode, the only valid file to serve is the one specified in `config.path`.
190191
if(mode === Mode.file) {
@@ -193,7 +194,7 @@ function IDEMessageHandler(client:SocketRuntimeClient, message) {
193194
}
194195

195196
// Otherwise, anything goes. First we check if the client has requested a specific file in the URL hash.
196-
if(mode === Mode.workspace && hash) {
197+
if(!isLocal && mode === Mode.workspace && hash) {
197198
// @FIXME: This code to strip the editor hash segment out really needs to be abstacted.
198199
let filepath = hash.split("#")[0];
199200
if(filepath[filepath.length - 1] === "/") filepath = filepath.slice(0, -1);
@@ -203,15 +204,15 @@ function IDEMessageHandler(client:SocketRuntimeClient, message) {
203204
}
204205

205206
// If we've got a path to run with, use it as the default.
206-
if(!content && config.path) {
207+
if(!isLocal && !content && config.path) {
207208
let workspace = "root";
208209
// @FIXME: This hard-coding isn't technically wrong right now, but it's brittle and poor practice.
209210
content = eveSource.get(config.path, workspace);
210211
path = eveSource.getRelativePath(config.path, workspace);
211212
}
212213

213214
// If we can't find the config path in a workspace, try finding it on disk.
214-
if(!content && config.path && fs.existsSync("." + path)) {
215+
if(!isLocal && !content && config.path && fs.existsSync("." + path)) {
215216
content = fs.readFileSync("." + path).toString();
216217
}
217218

0 commit comments

Comments
 (0)