hexenq / kuroshiro

Japanese language library for converting Japanese sentence to Hiragana, Katakana or Romaji with furigana and okurigana modes supported.
https://kuroshiro.org
MIT License
818 stars 93 forks source link

Error when setting dictPath to an https url #94

Open akukerang opened 2 years ago

akukerang commented 2 years ago

When using it an Chrome content script, setting the Kuromoji analyzer dict path to an https server, would just send a GET request to "https://currentsite.com/https://dhasdjashdkajdha.com/...". I would like it just for it to be "https://dhasdjashdkajdha.com/....". Using an http URL works fine, but Chrome would return the error "Mixed Content: The page at '<URL>' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint '<URL>'. This request has been blocked; the content must be served over HTTPS." Is there a way that I can set the dictPath to an https url?

import Kuroshiro from "kuroshiro";
// Initialize kuroshiro with an instance of analyzer (You could check the [apidoc](#initanalyzer) for more information):
// For this example, you should npm install and import the kuromoji analyzer first
import KuromojiAnalyzer from "kuroshiro-analyzer-kuromoji"
// Instantiate
const kuroshiro = new Kuroshiro();
// Initialize
// Here uses async/await, you could also use Promise
await kuroshiro.init(new KuromojiAnalyzer({
    dictPath: "https://dhasdjashdkajdha.com/"
}));
// Convert what you want
const result = await kuroshiro.convert("感じ取れたら手を繋ごう、重なるのは人生のライン and レミリア最高!", { to: "hiragana" });
console.log(result);
chinenvinicius commented 2 years ago

have u solved it? @akukerang

akukerang commented 2 years ago

@chinenvinicius no

chinenvinicius commented 2 years ago

seems like it calls dictpath on the index page but when i go to other pages. this dictfile deosnt load at all. only working on one page.

let kuroshiro = new Kuroshiro(); await kuroshiro.init(new KuromojiAnalyzer()); . this is the code . do u have the same issue? スクリーンショット (38)

akukerang commented 2 years ago

I kind of gave up trying to figure it out and I can't really remember what the error was exactly. Sorry about that.

jgaynor17 commented 1 year ago

seems like it calls dictpath on the index page but when i go to other pages. this dictfile deosnt load at all. only working on one page.

let kuroshiro = new Kuroshiro(); await kuroshiro.init(new KuromojiAnalyzer()); . this is the code . do u have the same issue? スクリーンショット (38)

did you solve this?

chinenvinicius commented 1 year ago

@jgaynor17 i couldnt solve it. but these have to do with core code. u need to use an old version of kuroshiro which work but it slow to donwload on the client . in my case it takes more than 30 seconds to dowload the whole library if speed is issue i would recommmend to implement it on the server side not client side. this issues is problay have to do on hotw dictionary is being passed on the code., kuroshiro.