thedevs_js | Unsorted

Telegram-канал thedevs_js - JavaScript

4853

Part of @thedevs Rules: @rulesforthedevs Join other dev groups https://thedevs.network

Subscribe to a channel

JavaScript

Hi guys I just added same new features on bloom https://github.com/hassanmiguel/Bloom-V.3.9.0. Kindly not I just add I didn't made the project from scratch bloom is free

Читать полностью…

JavaScript

Or literally anything else

Читать полностью…

JavaScript

Anyone up to join a hackathon

Читать полностью…

JavaScript

you just made a cliche meme

Читать полностью…

JavaScript

I did create a function returning two strings as object though as openat2 suggested

Читать полностью…

JavaScript

I've assumed you mean mailto: and sms: URLs, like the ones in Android or web links:
sms: / smsto: / mms: URLs return a String with the body.
mailto: URLs return a MailContent object with the subject and body.

import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

public final class MessageUrlParser {

public record MailContent(String subject, String body) {}

/**
* Parses a message URL.
*
* @return a {@link String} body for sms:/smsto:/mms: URLs,
* a {@link MailContent} for mailto: URLs
* @throws IllegalArgumentException for unsupported or malformed URLs
*/
public static Object parse(String url) {
if (url == null || url.isBlank()) {
throw new IllegalArgumentException("URL is empty");
}

int colon = url.indexOf(':');
if (colon < 0) {
throw new IllegalArgumentException("Missing scheme: " + url);
}
String scheme = url.substring(0, colon).toLowerCase();
String rest = url.substring(colon + 1);

Map<String, String> params = parseQuery(rest, scheme);

return switch (scheme) {
case "mailto" -> new MailContent(
params.getOrDefault("subject", ""),
params.getOrDefault("body", ""));
case "sms", "smsto", "mms", "mmsto" -> params.getOrDefault("body", "");
default -> throw new IllegalArgumentException("Unsupported scheme: " + scheme);
};
}

private static Map<String, String> parseQuery(String rest, String scheme) {
Map<String, String> params = new HashMap<>();

int start = rest.indexOf('?');
// iOS-style SMS links sometimes use '&' instead of '?': sms:123&body=hi
if (start < 0 && scheme.startsWith("sms")) {
start = rest.indexOf('&');
}
if (start < 0) {
return params;
}

for (String pair : rest.substring(start + 1).split("&")) {
if (pair.isEmpty()) continue;
int eq = pair.indexOf('=');
String key = decode(eq < 0 ? pair : pair.substring(0, eq)).toLowerCase();
String value = eq < 0 ? "" : decode(pair.substring(eq + 1));
params.putIfAbsent(key, value); // first occurrence wins
}
return params;
}

private static String decode(String s) {
// In mailto/sms URLs '+' is a literal plus, not a space (RFC 6068),
// so protect it before URLDecoder turns it into a space.
return URLDecoder.decode(s.replace("+", "%2B"), StandardCharsets.UTF_8);
}
}

Читать полностью…

JavaScript

This solution was kind of right even though the question was not proper

Читать полностью…

JavaScript

Yeah that would need another line of destructuring the object.

Читать полностью…

JavaScript

That would need another function fo its own then.

export const ver_subject = `Please verify email for food_app`,
ver_body = `
<p>Hi there,</p>
<p>Click the link below to verify your email address:</p>
<p><a href="${url}">Verify Email</a></p>
<p>This link expires in 1 hour.</p>
<p>If you didn't create an account, you can safely ignore this email.</p>
`;

This url variable is availbale where var_body is used only.

Читать полностью…

JavaScript

I have a string file to keep all strings in one place. Need to pass other variables in one of the string. Is there a way to do that?

Читать полностью…

JavaScript

I hope all of you who been using containerization for isolation/security have already migrated to MicroVMs.

The kernel sandbox escapes are getting more and more common accelerated by AI.

Here is CVE-2026-99999 with 9.3 score.

https://pwn.ai/blog/pwnescape

Читать полностью…

JavaScript

., sorry about that.

Читать полностью…

JavaScript

Far better reply than whatever you had sent and deleted. Thanks

Читать полностью…

JavaScript

What do you mean (lol, it's written in rust) ? I don't understand

Читать полностью…

JavaScript

jxl image format was finally shipped by chrome (lol, it's written in rust).

https://developer.chrome.com/blog/jpeg-xl-in-chrome

Читать полностью…

JavaScript

Posting about events like this is not suitable for a global group

Читать полностью…

JavaScript

Search it up on devpost

Читать полностью…

JavaScript

xeramail is supposed to send mails but it fails with the error too.

Читать полностью…

JavaScript

java in javascript chat, huh

Читать полностью…

JavaScript

What's this though. I am just using nodemailer for email verification there.

Читать полностью…

JavaScript

"import attributes" is simpler approach that won't fail on runtime.

import loginTemplate from "./login.html" with { type "text" };

//use loginTemplate accordingly

Читать полностью…

JavaScript

This is an expression not merely a "string".

Also, "I have a string file" is misleading if it's a normal JavaScript module file.

Читать полностью…

JavaScript

Create a function which takes url and returns a string of body or an object containing subject and body

Читать полностью…

JavaScript

Open the file then add the variable

Читать полностью…

JavaScript

I actually didn't migrate to Microvs

Читать полностью…

JavaScript

Does anyone want to collaborate with me to generate income?

Читать полностью…

JavaScript

It was written in C before, interesting

Читать полностью…

JavaScript

I meant its interesting to note that they rewrote the image decoder in rust.

Читать полностью…

JavaScript

What is the problem with Rust? In this case

Читать полностью…

JavaScript

SI will take care of that.

It's very efficient than humans in checking latest updates > checking vulnerabilities with new updates > ensuring deps are not broken.

Читать полностью…
Subscribe to a channel