jsonurl / jsonurl-js

JSON->URL defines a text format for the JSON data model suitable for use within a URL/URI (as described by RFC3986). This repository holds the JavaScript reference implementation of JSON->URL.
http://www.jsonurl.org/
MIT License
43 stars 7 forks source link

Cannot redefine property: toJsonURLText #614

Open SaalkT opened 1 year ago

dmaccormack commented 1 year ago

Hi, @SaalkT. You're correct that the toJsonURL property can not be redefined, but it can be defined on a per-instance basis during object creation. See this test for an example: https://github.com/jsonurl/jsonurl-js/blob/main/test/stringify.test.js#L181

Would that be sufficient for your use case?

AlonMiz commented 11 months ago

happens on next js, while rendering on the server side. maybe there's some kind of protection from reinitialization can be implemented

tonyxiao commented 9 months ago

@AlonMiz were you able to find a workaround?

tonyxiao commented 9 months ago

@dmaccormack this is more of a bug rather than enhancement.

AlonMiz commented 9 months ago

tonyxiao yes i've added an alias to my tsconfig

{
  "compilerOptions": {
    "paths": {
      // Creates 500s on our app when initializing
      // https://github.com/jsonurl/jsonurl-js/issues/614
      "@jsonurl/jsonurl": ["./node_modules/@jsonurl/jsonurl/dist/jsonurl.noproto"]
    },
    // ... more config
}
tonyxiao commented 9 months ago

but that doesn't work for javascript right?

AlonMiz commented 9 months ago

but that doesn't work for javascript right?

@tonyxiao try this

import JsonURL from '@jsonurl/dist/jsonurl.noproto';

or with require

const JsonURL =  require('@jsonurl/dist/jsonurl.noproto');
tonyxiao commented 9 months ago

Hmm that doesn't work in typescript anymore because there's no typedefinition for jsonurl.noproto

Speaking of which what does noproto mean anywyas?

joe223 commented 9 months ago

https://github.com/jsonurl/jsonurl-js/pull/660

ktheys commented 1 month ago

This issue is till not fixed. This happens server side on my Gatsby website. Please fix asap.

romulof commented 3 weeks ago

There's a discrepancy between the source: https://github.com/jsonurl/jsonurl-js/blob/v1.1.8/src/JsonURL.js#L1832 And the packaged code: https://www.runpkg.com/?@jsonurl/jsonurl@1.1.8/dist/jsonurl.noproto.js#2281