Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLSP-1101: Fix Windows path conversion #55

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/workflow-server-bundled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"wf-glsp-server-node.js.map"
],
"scripts": {
"clean": "rimraf ./*.js./*.js.map",
"clean": "rimraf wf-glsp-server-node.js wf-glsp-server-node.js.map",
"prepare": "yarn clean",
"start": "node --enable-source-maps ./wf-glsp-server-node.js --port 5007",
"start:websocket": "node --enable-source-maps ./wf-glsp-server-node.js -w --port 8081",
Expand Down
8 changes: 7 additions & 1 deletion packages/server/src/node/abstract-json-model-storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import { MaybePromise, RequestModelAction, SaveModelAction, TypeGuard } from '@eclipse-glsp/protocol';
import * as fs from 'fs-extra';
import { inject, injectable } from 'inversify';
import * as os from 'os';
import { fileURLToPath } from 'url';
import { ModelState, SOURCE_URI_ARG } from '../common/features/model/model-state';
import { SourceModelStorage } from '../common/features/model/source-model-storage';
Expand Down Expand Up @@ -91,7 +92,12 @@ export abstract class AbstractJsonModelStorage implements SourceModelStorage {
}

protected toPath(sourceUri: string): string {
return sourceUri.startsWith('file://') ? fileURLToPath(sourceUri) : sourceUri;
let path = sourceUri.startsWith('file://') ? fileURLToPath(sourceUri) : sourceUri;
if (os.platform() === 'win32') {
// Remove the leading slash if it exists (Windows paths don't have it)
path = path.replace(/^\//, '');
}
return path;
}

protected getFileUri(action: SaveModelAction): string {
Expand Down