@ -29,6 +29,7 @@
"use strict"
//
const monero _config = require ( './monero_config' )
const monero _utils = require ( './monero_cryptonote_utils_instance' )
//
const URITypes =
{
@ -85,9 +86,34 @@ function New_RequestFunds_URI(
}
exports . New _RequestFunds _URI = New _RequestFunds _URI
//
function New _ParsedPayload _From RequestURIString( uriString )
function New _ParsedPayload _From PossibleRequestURIString( string , nettype )
{ // throws; -> {}
// TODO
//
// detect no-scheme moneroAddr and possible OA addr - if has no monero: prefix
if ( string . indexOf ( monero _config . coinUriPrefix ) !== 0 ) {
const stringHasQMark = string . indexOf ( "?" ) !== - 1
if ( stringHasQMark ) { // fairly sure this is correct.. (just an extra failsafe/filter)
throw "Unrecognized URI format"
}
let couldBeOAAddress = string . indexOf ( "." ) != - 1 // contains period - would be nice to get this from DoesStringContainPeriodChar_excludingAsXMRAddress_qualifyingAsPossibleOAAddress so maybe mymonero_core_js should gain local_modules/OpenAlias
if ( couldBeOAAddress ) {
return {
address : string
}
}
var address _ _decode _result ;
try {
address _ _decode _result = monero _utils . decode _address ( string , nettype )
} catch ( e ) {
throw "No Monero request info"
return
}
// then it looks like a monero address
return {
address : string
}
}
const uriString = string
const url = new URL ( uriString )
const protocol = url . protocol
if ( protocol !== monero _config . coinUriPrefix ) {
@ -122,4 +148,4 @@ function New_ParsedPayload_FromRequestURIString(uriString)
//
return payload
}
exports . New _ParsedPayload _From RequestURIString = New _ParsedPayload _From RequestURIString
exports . New _ParsedPayload _From Possible RequestURIString = New _ParsedPayload _From Possible RequestURIString