メインコンテンツにスキップ

gas-url-shortener

A URL Shortening service powered by Google Apps Script.

AI Summary

TakeMeThere

Builds URL shortener with GAS and Sheets.

Target Users

Beginner GAS developers wanting custom domain URL shortener.

Problems Solved

Challenges in data management, redirects, and validations for GAS-based free URL shortener with custom domain.

Script ID

  1. In GAS Editor: Click "Libraries +" → Paste into "Script ID" field → Click "Look up"
  2. "gas-url-shortener" will appear in the search results
  3. Select the latest version (highest number) from "Version" dropdown
  4. Click "Add"

Tags

Main Features
1
Quick Setup

After spreadsheet creation, script config, run setup, deploy web app for backend.

2
Slug Validation

Alphanumeric only, banned keywords check, duplicate slug prevention.

3
Domain Support

Place HTML on GitHub Pages, DNS config for custom domain operation.

Examples

Main Functions

FunctionDescription
setupInitialize sheets
doGetHandle URL redirect

Examples

Code.gs Config
/**
 * Code.gs基本設定
 * ・シートID設定: const sheetID = '1xPs4Ht-3PVBGgdNSxyN3p2F5TtOifgvunrEvYaiu_A4'
 * ・カスタムドメイン設定: const customDomain = 'tmt.pw'
 * ・サービス名設定: const serviceName = 'TakeMeThere'
 */
const sheetID = '1xPs4Ht-3PVBGgdNSxyN3p2F5TtOifgvunrEvYaiu_A4';
const customDomain = 'tmt.pw';
const serviceName = 'TakeMeThere';

Run Setup
/**
 * スプレッドシート初期化
 * ・slug/URL/日付シート作成: SpreadsheetApp.openById(sheetID).insertSheet('Urls')
 * ・禁止キーワードシート作成: SpreadsheetApp.openById(sheetID).insertSheet('Banned')
 * ・デフォルトSheet1削除: SpreadsheetApp.openById(sheetID).getSheetByName('Sheet1').activate().deleteSheet()
 */
function setup() {
  // 承認後実行でシート作成削除を実施
}

Sample Code

Post a Sample

No sample codes for this library yet

Be the first to post a sample!

Post a Sample