@@ -58,65 +58,6 @@ trimIfString(input) {
5858 return ( typeof input === 'string' ) ? input . trim ( ) : input ;
5959} ,
6060
61- /* ===================================================================================================
62- Throws if not string or if not whole number.
63- ====================================================================================================== */
64-
65- throwIfNotStrOrId ( input , reason ) {
66- if ( typeof input === "number" ) {
67- this . throwIfNotWholeNumber ( input , reason ) ;
68- return ;
69- }
70-
71- if ( typeof input === "string" ) {
72- this . throwIfBlankOrNotString ( input , reason ) ;
73- return ;
74- }
75-
76- this . throwCustomError (
77- `Expected a non-empty string or a whole number. but got ${ typeof input } ` + this . _reasonMsg ( reason )
78- ) ;
79- } ,
80-
81-
82- /* ===================================================================================================
83- Checks if a string follows the YYYY-MM-DD date format.
84- Warns if the format or any individual part (year, month, day) is invalid.
85- ====================================================================================================== */
86-
87- checkYMDDashDate ( input ) {
88-
89- const warings = [ ] ;
90- this . throwIfBlankOrNotString ( input ) ;
91-
92- const parts = input . trim ( ) . split ( "-" ) ;
93-
94- if ( parts . length !== 3 ) {
95- warings . push ( "Date must be in format YYYY-MM-DD" + this . _reasonMsg ( input ) ) ;
96- } ;
97-
98- let [ year , month , day ] = parts ;
99-
100- // --- YEAR ---
101- year = + year ;
102- if ( ! Number . isInteger ( year ) || year < 1990 || year > 2100 ) {
103- warings . push ( "Year must be between 1990 and 2100" + this . _reasonMsg ( input ) ) ;
104- } ;
105-
106- const monthNum = + month ;
107- if ( month . length !== 2 || Number . isNaN ( monthNum ) || monthNum < 1 || monthNum > 12 ) {
108- warings . push ( `Month must be between 01 and 12. Got: '${ month } '` + this . _reasonMsg ( input ) ) ;
109- } ;
110-
111- const dayNum = + day ;
112- if ( day . length !== 2 || Number . isNaN ( dayNum ) || dayNum < 1 || dayNum > 31 ) {
113- warings . push ( `Day must be between 01 and 31. Got: '${ day } '` + this . _reasonMsg ( reason ) ) ;
114- } ;
115-
116- return warings ;
117-
118- } ,
119-
12061
12162/* ===================================================================================================
12263 Function tries to parse the input as JSON, If it is not return the value as it was passed
@@ -141,11 +82,6 @@ throwIfNotStrOrId(input, reason) {
14182 - Rejects blank strings, spaces, tabs, and newlines
14283 - Warns about suspicious or unusual characters
14384 - Adds a warning if protocol is missing or malformed
144- Returns:
145- {
146- warnings: string[],
147- url: string (trimmed original input)
148- }
14985====================================================================================================== */
15086 checkIfUrlValid ( input ) {
15187
@@ -167,7 +103,7 @@ throwIfNotStrOrId(input, reason) {
167103
168104 // Reject if spaces, tabs, or newlines are present
169105 if ( ( / [ \t \n ] / . test ( trimmedInput ) ) ) {
170- warnings . push ( `Url contains invalid characters like space, backslash etc., please check.` + this . _reasonMsg ( reason ) ) ;
106+ warnings . push ( `Url contains invalid characters like space, backslash etc., please check.` + this . _reasonMsg ( input ) ) ;
171107 return warnings ;
172108 } ;
173109
@@ -178,8 +114,7 @@ throwIfNotStrOrId(input, reason) {
178114
179115 if ( dubiousMatches ) {
180116 const uniqueChars = [ ...new Set ( dubiousMatches ) ] . join ( " " ) ;
181- warnings . push ( ` URL contains dubious or non-standard characters " ${ uniqueChars } " ` +
182- `that may be rejected by Google. Proceed only if you know what you are doing. ${ this . _reasonMsg ( reason ) } ` ) ;
117+ warnings . push ( ` URL contains dubious or non-standard characters ` + this . _reasonMsg ( input ) ) ;
183118 } ;
184119
185120 // urlObject for further use if the next check passes.
@@ -192,7 +127,7 @@ throwIfNotStrOrId(input, reason) {
192127 if ( / ^ ( h t t p s ? ) : \/ (? ! \/ ) / . test ( input ) ) {
193128
194129 warnings . push ( ` It looks like you're missing one slash after "${ urlObject . protocol } ".` +
195- `Did you mean "${ urlObject . protocol } //..."? ${ this . _reasonMsg ( reason ) } ` ) ;
130+ `Did you mean "${ urlObject . protocol } //..."? ${ this . _reasonMsg ( input ) } ` ) ;
196131
197132 } ;
198133
@@ -206,7 +141,7 @@ throwIfNotStrOrId(input, reason) {
206141
207142 } catch ( err ) {
208143 // If after all checks we are here that means that the url contain potentially unacceptable characters.
209- warnings . push ( ` URL contains potentionally unacceptable characters" ${ this . _reasonMsg ( reason ) } ` ) ;
144+ warnings . push ( ` URL contains potentionally unacceptable characters" ${ this . _reasonMsg ( input ) } ` ) ;
210145
211146 } ;
212147
@@ -220,18 +155,6 @@ throwIfNotStrOrId(input, reason) {
220155 Validates a Site Identifier string, which may be either:
221156 - A numeric Site ID (e.g., "123456")
222157 - A custom or subdomain (e.g., "mysite.example.com")
223-
224- The function:
225- - Throws on blank or non-string input
226- - Detects and skips further checks if the input is a valid numeric Site ID
227- - If the input is not numeric, performs domain checks:
228- - Warns if the input includes protocol (http:// or https://)
229- - Warns if it starts with 'www.'
230- - Warns about unusual characters (only letters, numbers, dots, and dashes are allowed)
231- - Warns if the domain does not contain at least one dot (.)
232-
233- Returns:
234- string[]: An array of warning messages (empty if input is clean)
235158====================================================================================================== */
236159
237160 checkDomainOrId ( input ) {
@@ -269,7 +192,7 @@ throwIfNotStrOrId(input, reason) {
269192
270193
271194 /* ===================================================================================================
272- throws a custom ERROR if axios request fails.
195+ Throws if axios request fails.
273196 Determines whether an error originated from your own validation code or from the API request.
274197 Useful for debugging and crafting more helpful error messages.
275198====================================================================================================== */
0 commit comments