Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzoronzani committed Dec 19, 2024
2 parents d5e2a19 + f6c76e4 commit 0a045a2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions libs/sdk-common/src/input_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ const LNURL_PAY_PREFIX: &str = "lnurl=";
/// }
/// ```
///
/// ### External input parsing
/// ## External input parsing
///
/// ```no_run
/// use sdk_common::prelude::{InputType::*, parse, ExternalInputParser};
Expand All @@ -176,7 +176,7 @@ const LNURL_PAY_PREFIX: &str = "lnurl=";
/// let external_parser = ExternalInputParser {
/// provider_id: "provider_id".to_string(),
/// input_regex: "(.*)(provider.domain)(.*)".to_string(),
/// parser_url: "http://external-parser-domain.com/{{input}}".to_string(),
/// parser_url: "http://external-parser-domain.com/<input>".to_string(),
/// };
///
/// let data = "151931provider.domain069135";
Expand Down Expand Up @@ -353,7 +353,7 @@ async fn parse_external(
// Build URL
let urlsafe_input =
percent_encoding::utf8_percent_encode(input, NON_ALPHANUMERIC).to_string();
let parser_url = parser.parser_url.replacen("{{input}}", &urlsafe_input, 1);
let parser_url = parser.parser_url.replacen("<input>", &urlsafe_input, 1);

// Make request
let parsed_value = match request_external_parsing(&parser_url).await {
Expand Down Expand Up @@ -835,7 +835,7 @@ pub struct ExternalInputParser {
pub provider_id: String,
/// The external parser will be used when an input conforms to this regex
pub input_regex: String,
/// The URL of the parser containing a placeholder `{{input}}` that will be replaced with the
/// The URL of the parser containing a placeholder `<input>` that will be replaced with the
/// input to be parsed. The input is sanitized using percent encoding.
pub parser_url: String,
}
Expand Down Expand Up @@ -1964,7 +1964,7 @@ pub(crate) mod tests {
let parsers = vec![ExternalInputParser {
provider_id: "id".to_string(),
input_regex: "(.*)(provider.domain)(.*)".to_string(),
parser_url: "http://127.0.0.1:8080/{{input}}".to_string(),
parser_url: "http://127.0.0.1:8080/<input>".to_string(),
}];

let input_type = parse(input, Some(&parsers)).await?;
Expand Down Expand Up @@ -2017,12 +2017,12 @@ pub(crate) mod tests {
ExternalInputParser {
provider_id: "bitcoin".to_string(),
input_regex: "(.*)(bitcoin.address.provider)(.*)".to_string(),
parser_url: "http://127.0.0.1:8080/{{input}}".to_string(),
parser_url: "http://127.0.0.1:8080/<input>".to_string(),
},
ExternalInputParser {
provider_id: "bolt11".to_string(),
input_regex: "(.*)(bolt11.provider)(.*)".to_string(),
parser_url: "http://127.0.0.1:8080/{{input}}".to_string(),
parser_url: "http://127.0.0.1:8080/<input>".to_string(),
},
];

Expand Down Expand Up @@ -2057,7 +2057,7 @@ pub(crate) mod tests {
let parsers = vec![ExternalInputParser {
provider_id: "id".to_string(),
input_regex: "(.*)(provider.domain)(.*)".to_string(),
parser_url: "http://127.0.0.1:8080/{{input}}".to_string(),
parser_url: "http://127.0.0.1:8080/<input>".to_string(),
}];

let result = parse(input, Some(&parsers)).await;
Expand Down

0 comments on commit 0a045a2

Please sign in to comment.