firebase / firebase-admin-node

Firebase Admin Node.js SDK
https://firebase.google.com/docs/admin/setup
Apache License 2.0
1.6k stars 358 forks source link

imageUrl with special characters, are not allowed in firebase messaging. But there exists a lots of image urls with different special characters. #1213

Open pavanyekabote opened 3 years ago

pavanyekabote commented 3 years ago

Environment:

Steps to reproduce:

import * as admin from 'firebase-admin';

let message: admin.messaging.MulticastMessage = {
    tokens: ["<fcmtokens>"],
    notification: {
        title: "This is a test notification on fcm",
        body: "This notification is to check if image with specials chars can be sent in fcm notification",
        imageUrl: "https://s.yimg.com/uu/api/res/1.2/8e4p0MNjKRtV25O3t_qSMw--~B/aD00MjU7dz04MDA7YXBwaWQ9eXRhY2h5b24-/https://media.zenfs.com/en/nextshark_articles_509/287cce64e3a1cd49446e8751b89262ef"
    }
}
admin.messaging().sendMulticast(message)
    .then((response: admin.messaging.BatchResponse) => {
        console.log("Message has been sent...");
    })
    .catch((error: any) => {
        console.log(error); 
        // This notification throws here, and flow comes in this section 
        // Error is "notification.imageUrl must be a valid URL string"
    });

As we see, the above example, the imageUrl has multiple special characters, still it is an URL which can surely load an image. But, firebase admin doesn't accept this.

Hope to see some upgrades in the pattern checking rules of imageUrl.

Thanks.

hiranya911 commented 3 years ago

It's not really a matter of special characters. Our existing path regex doesn't allow empty path segments, and the // in the middle of the path is interpreted as an empty path segment. Will see what we can do about that.

pavanyekabote commented 3 years ago

These days, the URLs are becoming too dynamic... However, thanks for " Will see what we can do about that.". Really grateful if a viable solution is implemented.

Thanks.

vulcantechsdevs commented 6 months ago

any update on this?

Quaybe commented 5 months ago

How am I supposed to specify an image if I can't use a "/" ??