@@ -33,16 +33,17 @@ import type { GridRange } from "./types";
3333 * parseA1Notation("'Sheet name'!A1:B2");
3434 * ```
3535 *
36- * @param a1Notation - The A1 notation string to parse.
37- * @returns An object representing the parsed grid range.
36+ * @param { string } a1Notation - The A1 notation string to parse.
37+ * @returns { GridRange } An object representing the parsed grid range.
3838 * @throws {@link IllegalArgumentException }
39+ * @see {@link parseA1Notations }
3940 * @see {@link GridRange }
4041 * @see {@link GoogleAppsScript.Spreadsheet.Range|Range }
4142 * @see {@link GoogleAppsScript.Spreadsheet.Sheet|Sheet }
4243 * @see [Class Range](https://developers.google.com/apps-script/reference/spreadsheet/range)
4344 * @see [Class Sheet](https://developers.google.com/apps-script/reference/spreadsheet/sheet)
4445 * @since 1.0.0
45- * @version 1.0.1
46+ * @version 1.1.0
4647 * @environment `Google Apps Script`, `Browser`
4748 * @author Maksym Stoianov <stoianov.maksym@gmail.com>
4849 * @license Apache-2.0
@@ -52,7 +53,7 @@ export function parseA1Notation(a1Notation: string): GridRange {
5253 throw new IllegalArgumentException ( ) ;
5354 }
5455
55- const trimmedInput = requireNonEmptyString ( a1Notation . trim ( ) ) ;
56+ const trimmedInput = requireNonEmptyString ( a1Notation ) . trim ( ) ;
5657
5758 let sheetName : string | null = null ;
5859 let rangeA1Part : string ;
@@ -268,32 +269,12 @@ export function parseA1Notation(a1Notation: string): GridRange {
268269 throw new SyntaxError ( `"${ a1Notation } " is not a valid A1 notation.` ) ;
269270 }
270271
271- let fullCanonicalA1Notation = "" ;
272- if ( sheetName !== null ) {
273- const isSimpleSheetName = / ^ [ A - Z _ ] [ A - Z 0 - 9 _ ] * $ / i. test ( sheetName ) ;
274-
275- if ( ! isSimpleSheetName ) {
276- if ( ! sheetName . includes ( "'" ) ) {
277- fullCanonicalA1Notation += `'${ sheetName } '!` ;
278- } else if ( ! sheetName . includes ( '"' ) ) {
279- fullCanonicalA1Notation += `"${ sheetName } "!` ;
280- } else {
281- fullCanonicalA1Notation += `'${ sheetName . replace ( / ' / g, "''" ) } '!` ;
282- }
283- } else {
284- fullCanonicalA1Notation += `${ sheetName } !` ;
285- }
286- }
287- fullCanonicalA1Notation += canonicalA1Notation ;
288-
289- const result : GridRange = {
272+ return {
290273 sheetName,
291- a1Notation : fullCanonicalA1Notation ,
274+ a1Notation : canonicalA1Notation ,
292275 startRowIndex : currentStartRowIndex ,
293276 endRowIndex : finalEndRowIndex ,
294277 startColumnIndex : currentStartColumnIndex ,
295278 endColumnIndex : finalEndColumnIndex
296279 } ;
297-
298- return result ;
299280}
0 commit comments