[FIX] web: keep full urls in settings
The function that adds the missing url root on documentation links uses a regex in startsWith, which is not supported. startsWith is replaced with ``regex.test`` which will succeed if the regex has any match. Which is fine because we use a '^' to ensure it *starts* with https task-3079113 closes odoo/odoo#110443 X-original-commit: fdaeaf69c1770edf3f33e32947326d1ebe42820e Signed-off-by: Jorge Pinna Puissant (jpp) <jpp@odoo.com>
This commit is contained in:
@@ -6,6 +6,8 @@ import { session } from "@web/session";
|
||||
import { FormLabelHighlightText } from "../highlight_text/form_label_highlight_text";
|
||||
import { Component, useState } from "@odoo/owl";
|
||||
|
||||
|
||||
const LINK_REGEX = new RegExp("^https?://");
|
||||
export class Setting extends Component {
|
||||
setup() {
|
||||
this.state = useState({
|
||||
@@ -56,7 +58,7 @@ export class Setting extends Component {
|
||||
}
|
||||
|
||||
get url() {
|
||||
if (this.props.documentation.startsWith("^https?://")) {
|
||||
if (LINK_REGEX.test(this.props.documentation)) {
|
||||
return this.props.documentation;
|
||||
} else {
|
||||
const serverVersion = session.server_version.includes("alpha")
|
||||
|
||||
@@ -89,7 +89,7 @@ QUnit.module("SettingsFormView", (hooks) => {
|
||||
</setting>
|
||||
</block>
|
||||
<block title="Title of group Foo">
|
||||
<setting help="this is foo">
|
||||
<setting help="this is foo" documentation="https://www.odoo.com/documentation/1.0/applications/technical/web/settings/this_is_another_test.html">
|
||||
<field name="foo"/>
|
||||
</setting>
|
||||
<setting string="Personalize setting" help="this is full personalize setting">
|
||||
@@ -139,10 +139,16 @@ QUnit.module("SettingsFormView", (hooks) => {
|
||||
target,
|
||||
".app_settings_block:not(.d-none) .app_settings_header .o_setting_box"
|
||||
);
|
||||
const docLinks = [...target.querySelectorAll(".o_setting_box a")];
|
||||
assert.strictEqual(docLinks.length, 2);
|
||||
assert.strictEqual(
|
||||
target.querySelector(".o_setting_box a").href,
|
||||
docLinks[0].href,
|
||||
"https://www.odoo.com/documentation/1.0/applications/technical/web/settings/this_is_a_test.html"
|
||||
);
|
||||
assert.strictEqual(
|
||||
docLinks[1].href,
|
||||
"https://www.odoo.com/documentation/1.0/applications/technical/web/settings/this_is_another_test.html"
|
||||
);
|
||||
|
||||
await editSearch(target, "Hello there");
|
||||
await execTimeouts();
|
||||
|
||||
Reference in New Issue
Block a user