Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
www
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PLN
www
Commits
e43bc5bb
Commit
e43bc5bb
authored
May 01, 2025
by
PLN (Algolia)
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Fix local hydra image urls on-the-fly
parent
4ec3fe11
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
+14
-3
hydra-view.js
next/components/hydra-view.js
+14
-3
No files found.
next/components/hydra-view.js
View file @
e43bc5bb
...
...
@@ -31,7 +31,16 @@ export default function HydraSynth({ source }) {
// Sanitize and prepare the source code
const
sanitizeHydraCode
=
(
code
)
=>
{
// Remove any HTML-like tags
const
sanitizedCode
=
code
.
replace
(
/<
[^
>
]
*>/g
,
''
);
let
sanitizedCode
=
code
.
replace
(
/<
[^
>
]
*>/g
,
''
);
// Replace local file paths with Git URLs - careful to preserve s0.initImage
sanitizedCode
=
sanitizedCode
.
replace
(
/initImage
\(
"file:
\/\/\/
home
\/
pln
\/
Work
\/
Hydra
\/(
.+
?)\/(
.+
?)
"
\)
/g
,
'initImage("https://git.nech.pl/pln/Hydra/raw/master/$1/$2")'
);
// Replace old domain with new domain
sanitizedCode
=
sanitizedCode
.
replace
(
/git
\.
plnech
\.
fr/g
,
'git.nech.pl'
);
// Trim whitespace and remove any leading/trailing backticks
return
sanitizedCode
.
trim
().
replace
(
/^`+|`+$/g
,
''
);
...
...
@@ -49,14 +58,16 @@ export default function HydraSynth({ source }) {
return
;
}
// Log the transformed code for debugging
console
.
log
(
"Running Hydra code with transformed paths"
);
// Attempt to evaluate the code
hydra
.
eval
(
cleanCode
);
}
catch
(
error
)
{
console
.
error
(
"Error running Hydra code:"
,
error
);
// Attempt to provide more context
console
.
log
(
"Original source code:"
,
code
);
console
.
log
(
"Sanitized code:"
,
sanitizeHydraCode
(
code
));
console
.
log
(
"Sanitized code error location:"
,
error
.
lineNumber
);
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment