> You'll notice that most of the code uses function chaining on a single line, but the cookie code puts method calls on a single line in the same style as the cookie examples on the website. I would also think a more commonly used JS implementation would use a simple for loop or RegEx matching to find cookies.
The point here is that this is one of the most simple ways to solve the problem, I am not stating that the code could be potentially derived from the sample, just that it's extremely unlikely. Both document and document.cookie are part of the browser's DOM (there is no other way to get/set cookie data) and methods such as split are the most idiomatic way to split a string into parts in modern Javascript which are honestly the only things that could claim are copied in good faith. > I would also think a more commonly used JS implementation would use a simple for loop or RegEx matching to find cookies. For old school Javascript using a loop may be typical but newer Javascript is more in style with functional programming and considering that both Pekko and Scala are functional programming in style it's actually quite rare to see people using normal loops for cases like this. > I would say the getCookie method looks to have been copied and modified a) due to the unusual way of finding a cookie This is not unusual at all, I wrote the exact code when I was younger working at a company without even reading MDN docs. The implementation may appear unusual but that's because browser cookies are stored in a very weird format (i.e. "name=oeschger; SameSite=None; Secure"; straight from the docs) and Javascript doesn't provide any native function for parsing that cookie content which means that pretty much every code running in a browser has some variation of this function (either written manually or via some library). So again if you told me how to write a function to get a single value from the cookie I would write const cookieAttr = decodeURIComponent(document.cookie) .split(";") .find(row => row.trimStart().startsWith(cookieName)) return cookieAttr ? cookieAttr.split("=")[1] : ""; As well. In fact if you wrote this in Scala.js (Scala to Javascript compiler) which is actually the native language the author programmed in at the time (who was actually Arnout Engelen) it would look like this val cookieAttr = decodeURIComponent(document.cookie) .split(";") .find(row => row.trim().startsWith(cookieName)) cookieAttr match { case Some(value) => cookieAttr.split("=")(1) case None => "" } In other words aside from the match statement (which has no equivalent in Javascript) it's exactly the same (split/startsWith are methods in JVM/Scala/Scala.js platform as well, trimStart doesn't exist but you can just use trim). Even this code document.cookie = `${cookieName}=${encodeURIComponent(cookieValue)};expires=${now.toUTCString()};path=/;samesite=lax`; would look almost exactly the same when written in functional Scala style, i.e. document.cookie = s"""${cookieName}=${encodeURIComponent(cookieValue)};expires=${now.toUTCString()};path=/;samesite=lax""" (Scala.js has the exact same String interpolation $ operator as Javascript, only difference is having an s prefix to indicate string interpolation is happening). The point I am saying is that as someone who wrote frontend Javascript for many years when I was younger and as well as being proficient in Scala/Java, if you put me in a courtroom and asked me if there is evidence that this code was copied and/or derived from that sample code I would say it's extremely unlikely as all possible similarities are trivia/easily independently reproducible. Furthermore if I then took into account the context of the author of code (i.e. person that writes in function Scala style as shown before), it makes it even more extremely unlikely. b) it uses the same formatting/style as the original example, which is different to the style of the rest of the code. The indentation/formatting/style of the code is entirely consistent https://github.com/lightbend/paradox/blob/8e30c341f1f8351a19b71599219d2f636ba68eb4/themes/generic/src/main/assets/js/groups.js, either in latest version or the original https://github.com/lightbend/paradox/commit/7f55c0c71bfbfc6a987c2693b19dcbb74c9dc9a3. This is not surprising as this standard for IDE's to format code this way and really this is actually just bog standard Javascript code there is nothing bespoke about it (either in totality of the code in a single file or the snippets in question). Doing things like putting chained method calls so that every method call is on its own line is almost universal for people writing that style of code because it's much easier to read. > You'll also note this comment in the code: // The lax value will send the cookie for all same-site // requests and top-level navigation GET requests. This // is sufficient for user tracking, but it will prevent // many CSRF attacks. This is the default value in modern browsers. As you said in this case it's an exact word for word copy and I think you can just remove the comment and reference the doc via a link. I can just ping the person that wrote this code (its Arnout) to ask him if he wrote it from scratch, but to me it sets a bad precedent to claim code is copied when there is so much counter evidence of that and none of the code is even novel in question and it's also unfair for the author. Its like if you asked someone to write Fibonacci sequence in Javascript with the only knowledge being the Fibonacci algorithm itself, pretty much almost everyone with proficient Javascript experience would write 2 variations (one with loop and one with recursion) and reading/setting cookie data is about as novel as Fibonacci. On Fri, Jul 14, 2023 at 3:43 AM Justin Mclean <jus...@classsoftware.com> wrote: > Hi, > > > So the groups.js has some documentation from that mozilla page copied > > as a comment. This is not an uncommon practice. The text is not in > > example code and most people would assume that the copying of small > > fragments of documentation as code comments is fair use. > > IANAL but fair use is complex and not easily defined, as no specific > amount of content may not be used safely without permission, and it varies > from country to country. Australia, for instance, has no fair use > provisions but much stricter fair dealing ones. Fair use also implies that > you have copied someone's IP without permission and are infringing on > someone's copyright, but want to claim that's OK under “fair use”. A better > option is not to copy other people's IP in the first place or if you do > abide by the terms that it is licensed under. > > What is more important here is how that content is licensed and what ASF > policy says about including 3rd party content. ASF policy goes further than > what is just the legal minimum. > > > Is there any non-comment content in groups.js that is copied? > > I would say the getCookie method looks to have been copied and modified a) > due to the unusual way of finding a cookie and b) it uses the same > formatting/style as the original example, which is different to the style > of the rest of the code. > > Kind Regards, > Justin > --------------------------------------------------------------------- > To unsubscribe, e-mail: general-unsubscr...@incubator.apache.org > For additional commands, e-mail: general-h...@incubator.apache.org > > -- Matthew de Detrich *Aiven Deutschland GmbH* Immanuelkirchstraße 26, 10405 Berlin Amtsgericht Charlottenburg, HRB 209739 B Geschäftsführer: Oskari Saarenmaa & Hannu Valtonen *m:* +491603708037 *w:* aiven.io *e:* matthew.dedetr...@aiven.io