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

Path separator on Windows is using backslashes #211

Closed
storm1ng opened this issue Jan 27, 2020 · 4 comments · Fixed by #213 or axa-ch/json-logic-js#24
Closed

Path separator on Windows is using backslashes #211

storm1ng opened this issue Jan 27, 2020 · 4 comments · Fixed by #213 or axa-ch/json-logic-js#24

Comments

@storm1ng
Copy link

What did you do

Generate schemas on Windows (previously on Unix/Linux)

What did you expect to happen

No changes in URL slashes (preserve regular forward slashes)

What happened

Forward slashes were replaced by backslashes

What's your environment

  • Operating System: Windows 10 1803
  • node.js version: 12.10.0

Do you have example files:

For this schema

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "$id": "http://jsonlogic.com/schemas/operators/arithmetic/add.json",

  "title": "+",
  "description": "Addition. Because addition is associative, it happily take as many args as you want. Passing just one argument to + casts it to a number.",

  "type": "object",
  "additionalProperties": false,
  "required": ["+"],
  "properties": {
    "+": {
      "$ref": "http://jsonlogic.com/schemas/common/one-or-more-args.json"
    }
  }
}

I'm getting following Markdown (git diff)

| Abstract            | Extensible | Status         | Identifiable            | Custom Properties | Additional Properties | Access Restrictions | Defined In                                                         |
| :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------ |
-| Can be instantiated | No         | Unknown status | Unknown identifiability | Forbidden         | Allowed               | none                | [add.json\*](operators/arithmetic/add.json "open original schema") |
+| Can be instantiated | No         | Unknown status | Unknown identifiability | Forbidden         | Allowed               | none                | [add.json\*](operators\arithmetic\add.json "open original schema") |                  

 ## properties Type                                                                                                                                                                                           

image

@storm1ng storm1ng changed the title Path separater on Windows is using backslashes Path separator on Windows is using backslashes Jan 27, 2020
@trieloff trieloff added the bug label Jan 28, 2020
@trieloff
Copy link
Collaborator

There might be an easy fix for this: replace this line:

const npath = require('path');

with an import to path.posix

I don't have a windows VM available, so a fix from my end might take a while, but I'm happy to review PRs.

@storm1ng
Copy link
Author

const npath = require('path').posix does not work.
It will change the output but not in the way we want:

-| Abstract            | Extensible | Status         | Identifiable            | Custom Properties | Additional Properties | Access Restrictions | Defined In                                                         |
-| :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------ |
-| Can be instantiated | No         | Unknown status | Unknown identifiability | Forbidden         | Allowed               | none                | [add.json\*](operators/arithmetic/add.json "open original schema") |
+| Abstract            | Extensible | Status         | Identifiable            | Custom Properties | Additional Properties | Access Restrictions | Defined In
                                                             |
+| :------------------ | ---------- | -------------- | ----------------------- | :---------------- | --------------------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Can be instantiated | No         | Unknown status | Unknown identifiability | Forbidden         | Allowed               | none                | [add.json\*](../C:\eplatform\git-repos\json-logic-js/C:\eplatform\git-repos\json-logic-js\schemas\operators\arithmetic\add.json "open original schema") |

@storm1ng
Copy link
Author

storm1ng commented Jan 30, 2020

A working solution would be to replace the os specific separator (npath.sep) with the posix one (npath.posix.sep):

        const target = npath.relative(
          mddir,
          npath.resolve(schemadir, npath.relative(srcdir, origin)),
        ).split(npath.sep).join(npath.posix.sep);

Not sure though if this covers all use cases.

AndyOGo added a commit to AndyOGo/jsonschema2md that referenced this issue Jan 30, 2020
Generating markdown on Windows uses the OS path seperator, backslash, not a valid URL path seperator

fix adobe#211
AndyOGo added a commit to AndyOGo/jsonschema2md that referenced this issue Jan 30, 2020
Generating markdown on Windows uses the OS path seperator, backslash, not a valid URL path seperator

fix adobe#211
trieloff pushed a commit that referenced this issue Jan 30, 2020
## [4.0.12](v4.0.11...v4.0.12) (2020-01-30)

### Bug Fixes

* dont use backslash for URLs on windows ([5149522](5149522)), closes [#211](#211)
@trieloff
Copy link
Collaborator

🎉 This issue has been resolved in version 4.0.12 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants