Boubou
1 month ago

SCRIPT5018: SCRIPT5018: Unexpected quantifier - Vuejs / js

Posted 1 month ago by Boubou

Hello,

I am having an error in vue.js that does not show up in Chrome(In chrome it works).

It is a script that downloads a zip file, I cannot work out what is going on, here is the script:

axios({
                    url: '/admin/zip',
                    method: 'GET',
                    responseType: 'arraybuffer',
                    params: {
                        id: id
                    }
                })
                .then(response => {
                    let blob = new Blob([response.data], {
                        type: 'application/zip'
                    });
                    const contentDisposition = response.headers['content-disposition'];
                    let fileName = 'SinNombre';
                    if (contentDisposition) {
                        const fileNameMatch = contentDisposition.match(/(?<=filename=).*/); <--------this one
                        fileName = fileNameMatch[0];
                    }

                    let link = document.createElement('a');
                    link.href = window.URL.createObjectURL(blob);
                    link.setAttribute('download', fileName);
                    link.click();
                })
                .catch(error => {
                });

In Microsoft hedge this line:

const fileNameMatch = contentDisposition.match(/(?<=filename=).*/);

Show this error:

SCRIPT5018: SCRIPT5018: Unexpected quantifier

Any idea why please?

Thanks!

Please sign in or create an account to participate in this conversation.