▲ 442 ▼ POV: You maintain a JS library that 80% of modern web infrastructure uses as a dependency. (lemmy.blahaj.zone) submitted 8 months ago by not_IO@lemmy.blahaj.zone to c/programmer_humor@programming.dev 49 comments fedilink hide all child comments 🤔 1
[–] MonkderVierte@lemmy.zip 13 points 8 months ago (8 children) And that's only one of the many reasons that JavaScript is a clown language. permalink fedilink source parent hideshow 8 child comments replies: [–] bleistift2@sopuli.xyz 4 points 8 months ago (7 children) Which of these things, excactly? That Math just floats around in the global scope? Or that that destructuring assignment works? Or that the author chose to abstract around Math.random(). That has come very handy for me when testing. permalink fedilink source parent hideshow 7 child comments replies: [–] MonkderVierte@lemmy.zip 8 points 8 months ago* (6 children) Global scope. Also that there's, after 35 years of webbrowsers, still no reliable way to match a domain without subdomain, except via string splitting. permalink fedilink source parent hideshow 6 child comments replies: [–] bleistift2@sopuli.xyz 6 points 8 months ago (4 children) I see your point regarding global scope. But personally, I’ve never encountered an issue with it. And it’s kinda nice not to have to import fetch every time you need it. Regarding subdomains, if you’ll humor my curiosity: What’s the use case? I also wonder what an API for this might look like. const {domain, subdomains, rootDomain} = new URL('https://wikipedia.org/') // 'wikipedia.org', [], 'wikipedia.org' const {domain, subdomains, rootDomain} = new URL('https://foo.bar.baz.net/') // 'foo.bar.baz.net', ['foo.bar.baz.net', 'bar.baz.net'], 'baz.net' permalink fedilink source parent hideshow 4 child comments replies: [–] MonkderVierte@lemmy.zip 4 points 8 months ago* (last edited 8 months ago) (3 children) A userscript over links for debugging purposes, that should ignore links to the same domain (www.w3schools vs campus.w3schools vs www.youtube). Btw, it's funny how support.mozilla and some standards-teaching-sites are some of the worst offenders of web standards. Edit: how to stop this auto-linking? permalink fedilink source parent hideshow 3 child comments replies: [–] bleistift2@sopuli.xyz 2 points 8 months ago (2 children) If I understand correctly, you want to check the current domain (eg. w3schools) against api.w3schools and www.youtube, and return true for the first and false for the second (or the other way around) Then technically it’s possible without string splitting: const href = 'retrieved-from-the-anchor-element'; (new URL(href, location.href).hostname).endsWith(location.hostname) permalink fedilink source parent hideshow 2 child comments replies: [–] MonkderVierte@lemmy.zip 3 points 8 months ago Well, the whole web is basically "let's go, make it work somehow". Thanks for your effort! permalink fedilink source parent [–] MonkderVierte@lemmy.zip 2 points 8 months ago Edit: got it working yesterday evening. But with split().slice(-2). Thanks again. permalink fedilink source parent [–] dreamkeeper@literature.cafe 2 points 8 months ago* Most scripting languages have a global scope of some kind. It's not that big of a deal. I'd prefer not to have it, but it hasn't caused me problems in many years. Actually, the window object can be really useful in some situations so I'm not even sure about that. permalink fedilink source parent
[–] bleistift2@sopuli.xyz 4 points 8 months ago (7 children) Which of these things, excactly? That Math just floats around in the global scope? Or that that destructuring assignment works? Or that the author chose to abstract around Math.random(). That has come very handy for me when testing. permalink fedilink source parent hideshow 7 child comments replies: [–] MonkderVierte@lemmy.zip 8 points 8 months ago* (6 children) Global scope. Also that there's, after 35 years of webbrowsers, still no reliable way to match a domain without subdomain, except via string splitting. permalink fedilink source parent hideshow 6 child comments replies: [–] bleistift2@sopuli.xyz 6 points 8 months ago (4 children) I see your point regarding global scope. But personally, I’ve never encountered an issue with it. And it’s kinda nice not to have to import fetch every time you need it. Regarding subdomains, if you’ll humor my curiosity: What’s the use case? I also wonder what an API for this might look like. const {domain, subdomains, rootDomain} = new URL('https://wikipedia.org/') // 'wikipedia.org', [], 'wikipedia.org' const {domain, subdomains, rootDomain} = new URL('https://foo.bar.baz.net/') // 'foo.bar.baz.net', ['foo.bar.baz.net', 'bar.baz.net'], 'baz.net' permalink fedilink source parent hideshow 4 child comments replies: [–] MonkderVierte@lemmy.zip 4 points 8 months ago* (last edited 8 months ago) (3 children) A userscript over links for debugging purposes, that should ignore links to the same domain (www.w3schools vs campus.w3schools vs www.youtube). Btw, it's funny how support.mozilla and some standards-teaching-sites are some of the worst offenders of web standards. Edit: how to stop this auto-linking? permalink fedilink source parent hideshow 3 child comments replies: [–] bleistift2@sopuli.xyz 2 points 8 months ago (2 children) If I understand correctly, you want to check the current domain (eg. w3schools) against api.w3schools and www.youtube, and return true for the first and false for the second (or the other way around) Then technically it’s possible without string splitting: const href = 'retrieved-from-the-anchor-element'; (new URL(href, location.href).hostname).endsWith(location.hostname) permalink fedilink source parent hideshow 2 child comments replies: [–] MonkderVierte@lemmy.zip 3 points 8 months ago Well, the whole web is basically "let's go, make it work somehow". Thanks for your effort! permalink fedilink source parent [–] MonkderVierte@lemmy.zip 2 points 8 months ago Edit: got it working yesterday evening. But with split().slice(-2). Thanks again. permalink fedilink source parent [–] dreamkeeper@literature.cafe 2 points 8 months ago* Most scripting languages have a global scope of some kind. It's not that big of a deal. I'd prefer not to have it, but it hasn't caused me problems in many years. Actually, the window object can be really useful in some situations so I'm not even sure about that. permalink fedilink source parent
[–] MonkderVierte@lemmy.zip 8 points 8 months ago* (6 children) Global scope. Also that there's, after 35 years of webbrowsers, still no reliable way to match a domain without subdomain, except via string splitting. permalink fedilink source parent hideshow 6 child comments replies: [–] bleistift2@sopuli.xyz 6 points 8 months ago (4 children) I see your point regarding global scope. But personally, I’ve never encountered an issue with it. And it’s kinda nice not to have to import fetch every time you need it. Regarding subdomains, if you’ll humor my curiosity: What’s the use case? I also wonder what an API for this might look like. const {domain, subdomains, rootDomain} = new URL('https://wikipedia.org/') // 'wikipedia.org', [], 'wikipedia.org' const {domain, subdomains, rootDomain} = new URL('https://foo.bar.baz.net/') // 'foo.bar.baz.net', ['foo.bar.baz.net', 'bar.baz.net'], 'baz.net' permalink fedilink source parent hideshow 4 child comments replies: [–] MonkderVierte@lemmy.zip 4 points 8 months ago* (last edited 8 months ago) (3 children) A userscript over links for debugging purposes, that should ignore links to the same domain (www.w3schools vs campus.w3schools vs www.youtube). Btw, it's funny how support.mozilla and some standards-teaching-sites are some of the worst offenders of web standards. Edit: how to stop this auto-linking? permalink fedilink source parent hideshow 3 child comments replies: [–] bleistift2@sopuli.xyz 2 points 8 months ago (2 children) If I understand correctly, you want to check the current domain (eg. w3schools) against api.w3schools and www.youtube, and return true for the first and false for the second (or the other way around) Then technically it’s possible without string splitting: const href = 'retrieved-from-the-anchor-element'; (new URL(href, location.href).hostname).endsWith(location.hostname) permalink fedilink source parent hideshow 2 child comments replies: [–] MonkderVierte@lemmy.zip 3 points 8 months ago Well, the whole web is basically "let's go, make it work somehow". Thanks for your effort! permalink fedilink source parent [–] MonkderVierte@lemmy.zip 2 points 8 months ago Edit: got it working yesterday evening. But with split().slice(-2). Thanks again. permalink fedilink source parent [–] dreamkeeper@literature.cafe 2 points 8 months ago* Most scripting languages have a global scope of some kind. It's not that big of a deal. I'd prefer not to have it, but it hasn't caused me problems in many years. Actually, the window object can be really useful in some situations so I'm not even sure about that. permalink fedilink source parent
[–] bleistift2@sopuli.xyz 6 points 8 months ago (4 children) I see your point regarding global scope. But personally, I’ve never encountered an issue with it. And it’s kinda nice not to have to import fetch every time you need it. Regarding subdomains, if you’ll humor my curiosity: What’s the use case? I also wonder what an API for this might look like. const {domain, subdomains, rootDomain} = new URL('https://wikipedia.org/') // 'wikipedia.org', [], 'wikipedia.org' const {domain, subdomains, rootDomain} = new URL('https://foo.bar.baz.net/') // 'foo.bar.baz.net', ['foo.bar.baz.net', 'bar.baz.net'], 'baz.net' permalink fedilink source parent hideshow 4 child comments replies: [–] MonkderVierte@lemmy.zip 4 points 8 months ago* (last edited 8 months ago) (3 children) A userscript over links for debugging purposes, that should ignore links to the same domain (www.w3schools vs campus.w3schools vs www.youtube). Btw, it's funny how support.mozilla and some standards-teaching-sites are some of the worst offenders of web standards. Edit: how to stop this auto-linking? permalink fedilink source parent hideshow 3 child comments replies: [–] bleistift2@sopuli.xyz 2 points 8 months ago (2 children) If I understand correctly, you want to check the current domain (eg. w3schools) against api.w3schools and www.youtube, and return true for the first and false for the second (or the other way around) Then technically it’s possible without string splitting: const href = 'retrieved-from-the-anchor-element'; (new URL(href, location.href).hostname).endsWith(location.hostname) permalink fedilink source parent hideshow 2 child comments replies: [–] MonkderVierte@lemmy.zip 3 points 8 months ago Well, the whole web is basically "let's go, make it work somehow". Thanks for your effort! permalink fedilink source parent [–] MonkderVierte@lemmy.zip 2 points 8 months ago Edit: got it working yesterday evening. But with split().slice(-2). Thanks again. permalink fedilink source parent
[–] MonkderVierte@lemmy.zip 4 points 8 months ago* (last edited 8 months ago) (3 children) A userscript over links for debugging purposes, that should ignore links to the same domain (www.w3schools vs campus.w3schools vs www.youtube). Btw, it's funny how support.mozilla and some standards-teaching-sites are some of the worst offenders of web standards. Edit: how to stop this auto-linking? permalink fedilink source parent hideshow 3 child comments replies: [–] bleistift2@sopuli.xyz 2 points 8 months ago (2 children) If I understand correctly, you want to check the current domain (eg. w3schools) against api.w3schools and www.youtube, and return true for the first and false for the second (or the other way around) Then technically it’s possible without string splitting: const href = 'retrieved-from-the-anchor-element'; (new URL(href, location.href).hostname).endsWith(location.hostname) permalink fedilink source parent hideshow 2 child comments replies: [–] MonkderVierte@lemmy.zip 3 points 8 months ago Well, the whole web is basically "let's go, make it work somehow". Thanks for your effort! permalink fedilink source parent [–] MonkderVierte@lemmy.zip 2 points 8 months ago Edit: got it working yesterday evening. But with split().slice(-2). Thanks again. permalink fedilink source parent
[–] bleistift2@sopuli.xyz 2 points 8 months ago (2 children) If I understand correctly, you want to check the current domain (eg. w3schools) against api.w3schools and www.youtube, and return true for the first and false for the second (or the other way around) Then technically it’s possible without string splitting: const href = 'retrieved-from-the-anchor-element'; (new URL(href, location.href).hostname).endsWith(location.hostname) permalink fedilink source parent hideshow 2 child comments replies: [–] MonkderVierte@lemmy.zip 3 points 8 months ago Well, the whole web is basically "let's go, make it work somehow". Thanks for your effort! permalink fedilink source parent [–] MonkderVierte@lemmy.zip 2 points 8 months ago Edit: got it working yesterday evening. But with split().slice(-2). Thanks again. permalink fedilink source parent
[–] MonkderVierte@lemmy.zip 3 points 8 months ago Well, the whole web is basically "let's go, make it work somehow". Thanks for your effort! permalink fedilink source parent
[–] MonkderVierte@lemmy.zip 2 points 8 months ago Edit: got it working yesterday evening. But with split().slice(-2). Thanks again. permalink fedilink source parent
[–] dreamkeeper@literature.cafe 2 points 8 months ago* Most scripting languages have a global scope of some kind. It's not that big of a deal. I'd prefer not to have it, but it hasn't caused me problems in many years. Actually, the window object can be really useful in some situations so I'm not even sure about that. permalink fedilink source parent