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

Could you support the primary keys in data attributes field??? (It is related to section 4.10 and section 5.11.) #5

Open
LuxWang opened this issue Aug 30, 2024 · 0 comments

Comments

@LuxWang
Copy link

LuxWang commented Aug 30, 2024

Could you please support the primary keys in data attributes field??? (It is related to section 4.10 and section 5.11.)
https://ref.gs1.org/standards/digital-link/uri-syntax/

‘data attributes’ MAY include AIs that may also be used as primary keys

Section_4_10
Section_5_11

I found this change "Suppressed restriction on only one primary key", however this is just partial support 4.10.
109bb36

for the current code base: https://github.com/gs1/GS1DigitalLinkCompressionPrototype/blob/master/src/GS1DigitalLinkToolkit.js

case 1: When the input string is "010000012300001780040001ABC" , the return value of gs1ElementStringsToGS1DigitalLink() is "https://id.gs1.org/8004/0001ABC"
However, the correct result should be "https://id.gs1.org/01/0100000123000017?8004=0001ABC" in section 5.11

var DigitalLink = new Object();

DigitalLink.Input = "010000012300001780040001ABC";
DigitalLink.Compressed = false
DigitalLink.ReadableAI = false
DigitalLink.BaseURL = null
DigitalLink.BaseURL = "https://id.gs1.org"
DigitalLink.Compressed = false
DigitalLink.ReadableAI = false

var gs1dlt = new GS1DigitalLinkToolkit();

var elementStringsNoBrackets = DigitalLink.Input;
elementStringsNoBrackets = elementStringsNoBrackets.replace(/^1/g, gs1dlt.groupSeparator); // replace all ^1 occurrences.

if (DigitalLink.Compressed) {
gs1dlt.gs1ElementStringsToCompressedGS1DigitalLink(elementStringsNoBrackets, DigitalLink.ReadableAI, DigitalLink.BaseURL);
}
else {
gs1dlt.gs1ElementStringsToGS1DigitalLink(elementStringsNoBrackets, DigitalLink.ReadableAI, DigitalLink.BaseURL);
}

case 2: when input string is "80040001ABC^10100000123000017" , the return value of gs1ElementStringsToGS1DigitalLink() is "https://id.gs1.org/8004/0001ABC"
However, the correct result should be "https://id.gs1.org/8004/00001ABC?01=0100000123000017" in section 5.11

var DigitalLink = new Object();

DigitalLink.Input = "80040001ABC^10100000123000017";
DigitalLink.Compressed = false
DigitalLink.ReadableAI = false
DigitalLink.BaseURL = null
DigitalLink.BaseURL = "https://id.gs1.org"
DigitalLink.Compressed = false
DigitalLink.ReadableAI = false

var gs1dlt = new GS1DigitalLinkToolkit();

var elementStringsNoBrackets = DigitalLink.Input;
elementStringsNoBrackets = elementStringsNoBrackets.replace(/^1/g, gs1dlt.groupSeparator); // replace all ^1 occurrences.

if (DigitalLink.Compressed) {
gs1dlt.gs1ElementStringsToCompressedGS1DigitalLink(elementStringsNoBrackets, DigitalLink.ReadableAI, DigitalLink.BaseURL);
}
else {
gs1dlt.gs1ElementStringsToGS1DigitalLink(elementStringsNoBrackets, DigitalLink.ReadableAI, DigitalLink.BaseURL);
}

Both case 1 and case 2 couldn't get similar results in 5.11.
Could you update the code for this part? Or could you please check if I misunderstand the document? thanks.

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

1 participant