fix(web-clipper): missing utils import

This commit is contained in:
Elian Doran 2026-01-24 11:25:32 +02:00
parent c0a2ae99cf
commit b5ff71b1a0
No known key found for this signature in database
4 changed files with 8 additions and 7 deletions

View File

@ -1,3 +1,4 @@
import { randomString } from "../../utils";
import TriliumServerFacade, { isDevEnv } from "./trilium_server_facade";
export default defineBackground(() => {

View File

@ -1,3 +1,5 @@
import { getBaseUrl, getPageLocationOrigin, randomString } from "../../utils.js";
export default defineContentScript({
matches: [
"<all_urls>"

View File

@ -16,15 +16,13 @@
"content_scripts": [
{
"js": [
"lib/browser-polyfill.js",
"utils.js"
"lib/browser-polyfill.js"
]
}
],
"background": {
"scripts": [
"lib/browser-polyfill.js",
"utils.js"
"lib/browser-polyfill.js"
]
},
"commands": {

View File

@ -1,4 +1,4 @@
function randomString(len) {
export function randomString(len) {
let text = "";
const possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
@ -9,7 +9,7 @@ function randomString(len) {
return text;
}
function getBaseUrl() {
export function getBaseUrl() {
let output = getPageLocationOrigin() + location.pathname;
if (output[output.length - 1] !== '/') {
@ -21,7 +21,7 @@ function getBaseUrl() {
return output;
}
function getPageLocationOrigin() {
export function getPageLocationOrigin() {
// location.origin normally returns the protocol + domain + port (eg. https://example.com:8080)
// but for file:// protocol this is browser dependant and in particular Firefox returns "null" in this case.
return location.protocol === 'file:' ? 'file://' : location.origin;