diff --git a/workbench b/workbench index f5cca68..05f3330 100755 --- a/workbench +++ b/workbench @@ -3352,6 +3352,13 @@ def create_redirects(): logging.warning(message) continue + if row["redirect_target"].lower().startswith("http") is False: + # It's an internal redirect. + redirect_target = f'internal:/{row["redirect_target"]}' + else: + # It's an external redirect. + redirect_target = row["redirect_target"] + # Check to see if the redirect source value is already a redirect. We don't use issue_request() # since we don't want to override config["allow_redirects"] for this one request. is_redirect_url = config["host"].rstrip("/") + "/" + row["redirect_source"] @@ -3377,7 +3384,7 @@ def create_redirects(): redirect = { "type": [{"value": "redirect"}], "redirect_source": [{"path": row["redirect_source"].lstrip("/").strip()}], - "redirect_redirect": [{"uri": row["redirect_target"].strip()}], + "redirect_redirect": [{"uri": redirect_target.strip()}], "status_code": [{"value": int(config["redirect_status_code"])}], } redirect_endpoint = config["host"] + "/entity/redirect?_format=json" @@ -3404,7 +3411,7 @@ def create_redirects(): + '" not created.' ) print("Error: " + message + " See log for more info.") - logging.error(message + "HTTP status code: " + str(response.status_code)) + logging.error(message + " HTTP status code: " + str(response.status_code)) if config["progress_bar"] is True: redirect_row_position = get_percentage(redirect_row_count, num_csv_records) diff --git a/workbench_utils.py b/workbench_utils.py index 4b81846..20b690b 100644 --- a/workbench_utils.py +++ b/workbench_utils.py @@ -3119,12 +3119,12 @@ def check_input(config, args): ) if path_exists_response.status_code == 404: message = ( - 'Redirect path "' + 'Redirect source path "' + row["redirect_source"].strip() + '" (row ' + str(count) + ") does not exist (HTTP response code is " - + str(is_redirect_response.status_code) + + str(path_exists_response.status_code) + "). This may be intentional." ) logging.warning(message)