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

Compression/Decompression and custom Path #2

Open
clementh59 opened this issue Oct 27, 2020 · 4 comments
Open

Compression/Decompression and custom Path #2

clementh59 opened this issue Oct 27, 2020 · 4 comments

Comments

@clementh59
Copy link

clementh59 commented Oct 27, 2020

Hi Mark,

I've tried to compress and decompress a Digital Link URI with a custom path and I had a problem.

Here is what I'm doing :

const input = 'https://example.com/some/other/path/info/01/09780345418913/21/12345';
const compress = Utils.compressWebUri(input);
const uncompress = Utils.decompressWebUri(compress);
expect(input).to.equal(uncompress);

But uncompress equals https://example.com/01/09780345418913/21/12345

Here are my compress and decompress functions :

const decompressWebUri = (uri, useShortText = false) =>
  toolkit.decompressGS1DigitalLink(uri, useShortText, getUriStem(uri));

const compressWebUri = (uri, useOptimisations = true, compressOtherKeyValuePairs = true) => {
  const uncompressedPrimary = false;
  const useShortText = false;

  return toolkit.compressGS1DigitalLink(
    uri,
    useShortText, // Not used
    getUriStem(uri),
    uncompressedPrimary, // Not used
    useOptimisations,
    compressOtherKeyValuePairs,
  );
};

Do you know where the issue comes from?

Thanks

@mgh128
Copy link
Contributor

mgh128 commented Oct 27, 2020

Hi Clément,

I think the problem is that the compression algorithm is not preserving the URI path info before the part that is specific to GS1 Digital Link, so /some/other/path/info is being lost in the round-trip. You can verify this at https://gs1.github.io/GS1DigitalLinkCompressionPrototype/ where you'll see that

https://example.com/some/other/path/info/01/09780345418913/21/12345

is compressed to

http://example.org/ARHKVAdpQkIKMDk

rather than

http://example.org/some/other/path/info/ARHKVAdpQkIKMDk

The good news is that the decompression algorithm will currently decompress

http://example.org/some/other/path/info/ARHKVAdpQkIKMDk to

http://example.org/gtin/09780345418913/ser/12345

so with some relatively minor adjustment of the decompression algorithm, we can arrange for it to decompress to

https://example.com/some/other/path/info/gtin/09780345418913/ser/12345
or
https://example.com/some/other/path/info/01/09780345418913/21/12345

The GS1 Digital Link compression algorithm currently starts with an associative array of GS1 Application Identifiers and their values - it does not currently start with an uncompressed GS1 Digital Link URI.

If you feel that this is a major problem, please mention this in the GS1 Digital Link v1.2 work group - but it would need some work to make the adjustment to the initial compression flowchart to start with an uncompressed GS1 Digital Link URI and a corresponding adjustment to the decompression flowcharts.

@clementh59
Copy link
Author

clementh59 commented Oct 28, 2020

Thanks for your answer.

I'll correct this issue in digital-link.js by adding the custom path directly after the compression and decompression.

@domguinard
Copy link

I think this should indeed be discussed in the group @mgh128 as it might be something the current description of the algorithm is missing, the issue is not so much that the custom path is not compressed (I do not think it would make sense) but that the compression algorithm's output will truncate it and hence is lossy.

@mgh128
Copy link
Contributor

mgh128 commented Oct 29, 2020 via email

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

No branches or pull requests

3 participants