openGraphScraper icon indicating copy to clipboard operation
openGraphScraper copied to clipboard

I hope it works even if the URL includes a language other than English.

Open junseo2323 opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. If the address contains non-english, return the following error. result: { success: false, requestUrl: 'velog.io/@skynet/오픈소스-기여-입문', error: 'Cannot convert argument to a ByteString because the character at index 24 has a value of 50724 which is greater than 255.', errorDetails: TypeError: Cannot convert argument to a ByteString because the character at index 24 has a value of 50724 which is greater than 255.

Describe the solution you'd like I have temporarily resolved this issue as follows. ` function encodeKoreanInURL(url : string) { const urlObj = new URL(url);

const searchParams = new URLSearchParams(urlObj.search);
searchParams.forEach((value, key) => {

    if (/[\u3130-\u318F\uAC00-\uD7AF]/.test(value)) {
        searchParams.set(key, encodeURIComponent(value));
    }
});
urlObj.search = searchParams.toString();
return urlObj.toString();
}
 const data = await ogs({url: encodeKoreanInURL(reqUrl)})        
        const {result} = data
        resdata = result

`

Additional context If a language other than English is in the address, you will be able to fix it by correcting it through codeURIComponent.

junseo2323 avatar Sep 08 '24 05:09 junseo2323